﻿

// JavaScript Documentfunction gettheDate() {

var timerID = null;
var timerRunning = false;

function showtime() {

    var currentTime = new Date()
    var month = currentTime.getMonth() + 1
    var day = currentTime.getDate()
    var year = currentTime.getFullYear()
    ///
    var now = new Date();
    var hours = currentTime.getHours();
    var minutes = currentTime.getMinutes();
    var seconds = currentTime.getSeconds();

    var timeValue = getVietNamesDayName(currentTime.getDay()) + " , Ngày " + day + "/" + month + "/" + year + " - " + ((hours > 12) ? hours - 12 : hours);
    timeValue += ((minutes < 10) ? ":0" : ":") + minutes;
    timeValue += ((seconds < 10) ? ":0" : ":") + seconds;
    timeValue += (hours >= 12) ? " P.M." : " A.M.";
    if (timeValue.length < 210) {
        if (getVietNamesDayName(currentTime.getDay()) == "Chủ nhật")
            timeValue = "  " + timeValue;
        else
            timeValue = "       " + timeValue;
    }
    var datetimeid = document.getElementById("datetime");
    datetimeid.value = timeValue;
    timerID = setTimeout("showtime()", 1000);
    timerRunning = true;
}
function showtimeEngLish() {

    var currentTime = new Date()
    var month = currentTime.getMonth() + 1
    var day = currentTime.getDate()
    var year = currentTime.getFullYear()
    ///

    var hours = currentTime.getHours();
    var minutes = currentTime.getMinutes();
    var seconds = currentTime.getSeconds();
    var timeValue = currentTime.toLocaleDateString() + " - " + ((hours > 12) ? hours - 12 : hours);
    timeValue += ((minutes < 10) ? ":0" : ":") + minutes;
    timeValue += ((seconds < 10) ? ":0" : ":") + seconds;
    timeValue += (hours >= 12) ? " P.M." : " A.M.";
    if (timeValue.length < 210) {
        timeValue = " " + timeValue;
    }
    var datetimeid = document.getElementById("datetime");
    datetimeid.value = timeValue;
    timerID = setTimeout("showtimeEngLish()", 1000);
    timerRunning = true;
}
function getVietNamesDayName(num) {
    var day = new Array("Chủ nhật", "Thứ 2", "Thứ 3", "Thứ 4", "Thứ 5", "Thứ 6", "Thứ 7");

    return day[num];
}
function getEngLishDayName(num) {
    var day = new new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
    return day[num];
}			
					
