Standard library / archive/zip

archive/zip.FileHeader.SetModTime()

Deprecated setter for modification time and legacy DOS fields. Prefer assigning Modified. Expected stdout: '2024\n'.

Formal Syntax & Structure

go syntaxgo
func (h *FileHeader) SetModTime(t time.Time)

Parameters & Attributes

NameTypeDescription
ttime.TimeModification timestamp.

Working Example

Example Snippetgo
package main
import (  "archive/zip"  "fmt"  "time")
func must(e error) {  if e != nil {    panic(e)  }}
func main() {  h := zip.FileHeader{}  h.SetModTime(time.Date(2024, 1, 2, 3, 4, 6, 0, time.UTC))  fmt.Println(h.Modified.Year())}
Go Reference