Displaying Date in “Month dd, yyyy” format

Displaying Date in “Month dd, yyyy” format

We can display date in “Month dd, yyyy” format using javascript as follows. We can place the following code between <HEAD> and </HEAD> tags:

<SCRIPT language=Javascript>
var today_date= new Date()
var month=today_date.getMonth()
var today=today_date.getDate()
var year=today_date.getYear()

var months_arr = new Array(
“January”,
“February”,
“March”,
“April”,
“May”,
“June”,
“July”,
“August”,
“September”,
“October”,
“November”,
“December”);
</SCRIPT>

We can place this code where we would like the date to appear:

<SCRIPT language=Javascript>

document.write(months_arr[month]+” “+today+”, “+year)

</SCRIPT>

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.