Labels

php (35) javascript (31) phpjavascript (30) jquery (23) html (20) mysql (14) database (9) codeigniter (4) json (4) bar chart (2) calendar (2) column chart (2) framework (2) google maps (2) query (2) tables (2) url (2) dropdown (1)

Thursday, January 25, 2018

How to Display Date Using Javascript?

This JavaScript code will display today date. 

<SCRIPT LANGUAGE="JavaScript">
    var now = new Date();

    var days = new Array('Sunday','Monday','Tuesday',
        'Wednesday','Thursday','Friday','Saturday');

    var months = new Array('January','February','March','April',
        'May','June','July','August','September',
        'October','November','December');

    var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();

    function yearName(number)  {
        return (number < 1000) ? number + 1900 : number;
    }
    today =  days[now.getDay()] + ", " +
        months[now.getMonth()] + " " +
        date + ", " +
        (yearName(now.getYear())) ;

    document.write(today);
</script>

Result:

Thursday, January 25, 2016

6 comments:

More Posts

Subscribe Us

FOLLOW