how to format datetime in http/template?

9,778 views
Skip to first unread message

John Qin

unread,
Jun 3, 2014, 9:55:59 PM6/3/14
to golan...@googlegroups.com
here's the code.  i try  to format the date to following two formats.

{{.CreatedOn.Format "2014-01-02"}} <br/>
{{.CreatedOn.Format "Wednesday, October 16, 2013"}}

I am getting this weird date back.

30655-06-03 
WEDNESDAY, OCTOBER 66, 3068

Jesse McNelis

unread,
Jun 3, 2014, 10:10:14 PM6/3/14
to John Qin, golang-nuts
Read the time pkg docs for the correct format of the time format string.
http://golang.org/pkg/time/#pkg-constants

John Qin

unread,
Jun 3, 2014, 10:27:13 PM6/3/14
to golan...@googlegroups.com, myw...@gmail.com, jes...@jessta.id.au
thank you so much. I didnt realize I have to use the year , date, month listed on their page.  now its working.
Reply all
Reply to author
Forward
0 new messages