Subscribe

How To Easily Format Dates With JavaScript

I recently wanted to format a date with JavaScript and found it quite hard. There are no really good built in functions for date formatting in JavaScript.

Enter Steven Levithan's JavaScript Date Format.

Here's an example on how to format a date that looks like this: 2011-02-16 | 14:58

var myDate = new Date().format('yyyy-mm-dd | HH:MM');

Really smooth and easy.

You can find a lot of custom date format examples + a reference in Steven's blog post.

Write a comment





Or use Twitter to identify


To the top