What is the equivalent code in golang for the following shell command ? date -u +%Y-%m-%dT%T%z
The date. toISOString() method is used to convert the given date object's contents into a string in ISO format (ISO 8601) i.e, in the form of (YYYY-MM-DDTHH:mm:ss. sssZ or ±YYYYYY-MM-DDTHH:mm:ss.
Universal Coordinate Time is the time at the zero meridian, near Greenwich, England. UTC is a datetime value that uses the ISO 8601 basic form yyyymmddT hhmmss+|– hhmm or the ISO 8601 extended form yyyy-mm-ddT hh:mm:ss+|– hh:mm.
Coordinated Universal Time (UTC) Z is the zone designator for the zero UTC offset. "09:30 UTC" is therefore represented as "09:30Z" or "T0930Z".
package main import ( "time" "fmt" ) func main(){ fmt.Println(time.Now().Format(time.RFC3339)) }
golang Time.Format
package main import ( "fmt" "time" ) func main() { fmt.Println(time.Now().UTC().Format("2006-01-02T15:04:05-0700")) }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With