Start Free Trial
Rise Vision Blog

Product News, Customer Stories and Updates from Rise Vision

Formatting Dates in Javascript

Get Started With Rise Vision

As all Javascript Developers know, to work with dates in Javascript you would use the Date object. No surprise there. But what if you want to display a date in your digital signage open source Gadget or Presentation in a particular format, say, November 1st, 2011? Although the Date object has numerous methods for manipulating dates, it is rather limited when it comes to formatting those dates.

I've heard it said that the best Developer is a lazy Developer. Taking this advice to heart, I set out to see if somebody else had already built something that I could use. Happily, I discovered Datejs. Datejs is an open source Javascript library that makes it super simple to not only format dates, but to parse and process them as well. For example, to show today's date as November 1st, 2011, all we have to do is add one line of code:"MMMM dS, yyyy")

Datejs can do other cool things like determine if a given year is a leap year, check whether Daylight Saving Time is observed in the current time zone, and add seconds, minutes, hours or days to a given date.

You can find the documentation for Datejs here. I'm sure you will find this library quite handy the next time you find yourself having to do advanced date processing or formatting in your Gadgets or Presentations.

Keep your displays interesting - pick new templates every week!

Every week, we send Template recommendations that will make you look great and improve your audience experience. And the best part, they save up to 16 hours of content creation time every week.

Not convinced? Check out the email we sent last week.