Playing with Dates in Dojo

To convert a ISOString into a Date object, use dojo.date.stamp.fromISOString. For example:

var dateObj = dojo.date.stamp.fromISOString("2011-04-26T19:30:40+0000"))

To convert a Date object into a localized date format which you would like, 3 parameters I regularly tend to use are “selector” and “formatLength” and “datePattern”:

dojo.date.locale.format( dateObj, {selector:'date', formatLength:'full'} )
//returns  "Tuesday, April 26, 2011"

You can also specify different datePatterns like datePattern: “yyyyMMdd”, etc. More details here.

A useful link for confirming to regular cultural conventions here.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s