strftime() in JavaScript
Philip "Bluesmoon" Tellis has posted a tiny (under 3K minified) JavaScript library to format dates, inspired by PHP's strftime()
Examples:
d.strftime('%Y/%m/%d')
» en: 2008/04/25
» fr: 2008/04/25
» de: 2008/04/25
d.strftime('%A, %d %B')
» en: Friday, 25 April
» fr: Vendredi, 25 Avril
» de: Freitag, 25 April
There's also a demo to fiddle with.
I've previously had fun with kinda like the opposite: translating human-readable times into JS Date objects. Also here and here you have strtotime() look-alikes that take human-readable dates and turn them into Date objects.
This entry was posted on Friday, April 25th, 2008 and is filed under JavaScript, php. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Get notification for future posts: follow me on Twitter or subscribe to my RSS feed

March 3rd, 2009 at 6:53 pm
I like it. I’ve also been using the date parsing lib from Baron Schwartz
http://code.google.com/p/flexible-js-formatting/
January 5th, 2011 at 4:21 am
I admire the valuable information you offer in your articles. I will bookmark your blog and have my children check up here often. I am quite sure they will learn a lots of new stuff here than anybody else!
November 19th, 2011 at 7:49 pm
horacio…
[...]strftime() in JavaScript / Stoyan’s phpied.com[...]…
February 10th, 2012 at 12:20 am
Ikusi dut duzun got post berri bat i oro har bultzatuko baino gehiago hemen, ez dute i esker esan til orain comment-etan argitaratua, i maite zure mezuak. Eskerrik asko!
March 19th, 2013 at 2:56 am
I’m really impressed! Great work, nice, clean and efficient! Well written, bravo!!
Question: Is there a way to link “navigator.language” by default?
So I could write:
out=new Date(inputValue).strftime(‘%a %d %b %Y %T’);
instead of:
out=new Date(inputValue);
out.locale=navigator.language;
out=cont.strftime(‘%a %d %b %Y %T’);
Thanks for sharing this!!