What ‘T’ and ‘Z’ means in date

ISO 8601 The ISO 8601 standard defines formats for representing date-time values as text. The T is just a marker for where the time part begins. The Z is an abbreviation of +00:00, meaning UTC (an offset of zero hour-minutes-seconds). Pronounced “Zulu” per military and aviation tradition. From the Wikipedia article on ISO 8601 A … Read more

Parsing date/time strings which are not ‘standard’ formats

There are some key values that the time.Parse is looking for. By changing: test, err := time.Parse(“10/15/1983”, “10/15/1983”) to test, err := time.Parse(“01/02/2006”, “10/15/1983”) the parser will recognize it. Here’s the modified code on the playground. package main import “fmt” import “time” func main() { test, err := time.Parse(“01/02/2006”, “10/15/1983”) if err != nil { … Read more

Will a docker container auto sync time with its host machine?

If you are on OSX running boot2docker, see this issue: https://github.com/boot2docker/boot2docker/issues/290 Time synch becomes an issue because the boot2docker host has its time drift while your OS is asleep. Time synch with your docker container cannot be resolved by running your container with -v /etc/localtime:/etc/localtime:ro Instead, for now, you have to periodically run this on … Read more

Go time.Now().UnixNano() convert to milliseconds?

The 2021 answer: As of go v1.17, the time package added UnixMicro() and UnixMilli(), so the correct answer would be: time.Now().UnixMilli() Original answer: Just divide it: func makeTimestamp() int64 { return time.Now().UnixNano() / int64(time.Millisecond) } Here is an example that you can compile and run to see the output package main import ( “time” “fmt” … Read more

Benchmarking programs in Rust

It might be worth noting two years later (to help any future Rust programmers who stumble on this page) that there are now tools to benchmark Rust code as a part of one’s test suite. (From the guide link below) Using the #[bench] attribute, one can use the standard Rust tooling to benchmark methods in … Read more

How to format current time using a yyyyMMddHHmmss format?

Use fmt.Println(t.Format(“20060102150405”)) as Go uses following constants to format date,refer here const ( stdLongMonth = “January” stdMonth = “Jan” stdNumMonth = “1” stdZeroMonth = “01” stdLongWeekDay = “Monday” stdWeekDay = “Mon” stdDay = “2” stdUnderDay = “_2” stdZeroDay = “02” stdHour = “15” stdHour12 = “3” stdZeroHour12 = “03” stdMinute = “4” stdZeroMinute = “04” … Read more