﻿function GetClientTime() {

    var now = new Date();

    var ampm = ' PM';
    var minutes = now.getMinutes();
    var seconds = now.getSeconds();
    var hours = now.getHours();

    if (minutes < 10)
        minutes = '0' + minutes;

    if (seconds < 10)
        seconds = '0' + seconds;

    if (hours > 12)
        hours = hours - 12;
    else {
        if (hours == 0)
            hours = 12;

        ampm = ' AM';
    }

    var clienttime = hours + ':' + minutes + ':' + seconds + ampm;

    var month = (now.getMonth() + 1);
    var day = now.getDate();
    var year = now.getFullYear();

    // (mm/dd/yyyy)
    var datetime = month + '/' + day + '/' + year + " " + clienttime;

    // format local time (mm/dd/yyyy hh:mm:ss ampm)
    $('#client-datetime').html(datetime);

    setTimeout('GetClientTime()', 1000);
}

