Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q724 How can I display the date in the format weekday, dd, month, year, for example Friday, 11 Dec 1998?

You are here: irt.org | FAQ | JavaScript | Date | Q724 [ previous next ]

Try:

<SCRIPT LANGUAGE = 'JavaScript'><!--
function makeArray() {
    for (i = 0; i<makeArray.arguments.length; i++)
        this[i + 1] = makeArray.arguments[i];
}

function makeArray0() {
    for (i = 0; i<makeArray0.arguments.length; i++)
        this[i] = makeArray0.arguments[i];
}

function y2k(number) { return (number < 1000) ? number + 1900 : number; }

var months = new makeArray('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var days = new makeArray0('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');

var today = new Date();
var day   = days[today.getDay()];
var date  = today.getDate();
var month = today.getMonth() + 1;
var year  = y2k(today.getYear());

document.write(day + ', ' + date + ' ' + months[month] + ' ' + year);
//--></SCRIPT>

Feedback on 'Q724 How can I display the date in the format weekday, dd, month, year, for example Friday, 11 Dec 1998?'

©2018 Martin Webb