Share on Google+Share on Google+

JavaScript Date Function

Advertisement
JavaScript Date Functions: Many language provide special functions for Date, JavaScript also provides many functions for it. Given examples will illustrate the functions. In this tutorial you will come to know about different functions provided by JavaScript

JavaScript Date Function

Many language provide special functions for Date, JavaScript also provides many functions for it. Given examples will illustrate the functions.

JavaScript Date Function Example:

<html>
<head>
<script type="text/javascript">
document.write("<br/><b>Today's date is:</b><br/>");
document.write(Date());
var d=new Date();
document.write("<br/><b>Miliseconds from 01/01/1970 is:</b><br/>");
document.write(d.getTime());
document.write("<br/><b>Today is:</b><br/>");
var s=d.getDay();
switch(s)
{
	case 0:
		document.write("Sunday");
		break;
	case 1:
		document.write("Monday");
		break;
	case 2:
		document.write("Tuesday");
		break;
	case 3:
		document.write("Wednesday");
		break;
	case 4:
		document.write("Thursday");
		break;
	case 5:
		document.write("Friday");
		break;
	case 6:
		document.write("Saturday");
		break;
}
</script>
</head>
</html>

Output:

 Today's date is:
Sat Nov 07 18:20:10 2009
Miliseconds from 01/01/1970 is:
1257598210937
Today is:
Saturday

Advertisements

Advertisement

Posted on: November 7, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.