I'd like to rename some files based on their modification date.
When I use the time.Format
method to get the correct string, basically in this format YYYY-MM-DD_HH-MM-SS
, the day has a trailing 0
.
Am I doing something wrong here?
package main
import (
"time"
"fmt"
)
func main() {
loc, _ := time.LoadLocation("Europe/Berlin")
const layout = "2006-01-20_15-04-05"
t := time.Date(2013, 07, 23, 21, 32, 39, 0, loc)
fmt.Println(t)
fmt.Println(t.Format(layout))
}
Output:
2013-07-23 21:32:39 +0200 CEST 2013-07-230_21-32-39