Time

nooutput

fmt := import("fmt")
times := import("times")
now := times.now()
fmt.println(times.time_format(now, "2006-01-02"))
fmt.println(times.time_format(now, times.format_rfc3339))
fmt.println("year: ", times.time_year(now))
fmt.println("month: ", times.month_string(times.time_month(now)))
fmt.println("day:  ", times.time_day(now))
past := times.parse("2006-01-02", "2001-09-09")
fmt.println(times.time_format(past, "January 2, 2006"))
diff := times.sub(now, past)
days := times.duration_hours(diff) / 24
fmt.printf("%.0f days since then\n", days)

try it

$ (output will appear here)
loading…