Sunday, 23 November 2014

Find out the day of the week by given date in jquery

var days = [
    'SUN', //Sunday starts at 0
    'MON',
    'TUE',
    'WED',
    'THU',
    'FRI',
    'SAT'
];

d = new Date(); //This returns Wed Apr 02 2014 17:28:55 GMT+0800 (Malay Peninsula Standard Time)
x = d.getDay(); //This returns a number, starting with 0 for Sunday

alert (days[x]);

No comments:

Post a Comment