Thursday, December 23, 2010

JavaScript | Static Current Date Format

<script type="text/javascript">
var today = new Date();
var d = today.getDate();
var m = today.getMonth();
var y = today.getFullYear();
var months = new Array("January", "February", "March", "April", "May", "June", "Jully", "August", "September", "October", "November", "December");
datestr = months[m] + " " + d + ", " + y;

This displays always "Month Day, Year", regardless of user browser language, or system regional settings.

The code can be added in-line, where it is needed within the html.

No comments:

Post a Comment