Tuesday, April 24, 2012

Datejs - JavaScript Date library

Datejs is an open-source JavaScript Date library.

Example:


<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Mobile-Web-App: Javascript Exercise - Datejs</title>
<script src="http://www.datejs.com/build/date.js" type="text/javascript"></script>
<script>

function test(){

info = "<p><b>Datejs: an open-source JavaScript Date library</b></p>"
 + "<p> Today's date: " + Date.today() + "</p>"
 + "<p> Add 5 days to today: " + Date.today().add(5).days() + "</p>"
 + "<p> Get Friday of this week: " + Date.friday() + "</p>" 
 + "<p> Get March of this year: " + Date.march() + "</p>"
 + "<p> Is today Friday? " + Date.today().is().friday() + "</p>";

document.getElementById("prompt").innerHTML=info;
}

</script>
</head>
<body onload="test();">
<h1>Mobile-Web-App: Javascript Exercise - Datejs</h1>
<div id="prompt"></div>
</body>
</html>


No comments:

Post a Comment