JavaScript – Date Display
<!DOCTYPE html> <html> <head> <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 fourdigits(number) { return (number < 1000) ? number + 1900 : number; } // Create the date today = days[now.getDay()] + ", " + months[now.getMonth()] + " " + date + ", " + (fourdigits(now.getYear())) ; document.write(today); // print on screen the date </script> </head> <body> </body> </html>
Notice the 2 arrays:
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');
To change language you need rewrite the data of var days-months.
The final result is:
Saturday, November 23, 2013