|
Javascript Date Object Extra Functions |
Return to Index | ||
These functions are not part of the Javascript Date Object functionality. They are specially written to operate on the Date Object in order to provide useful display strings. The functions are defined in the file jsdatefuncs.js (click on the link to view it). The file is included in the <head> section of this and any other file that uses it like this:
<script type="text/javascript" language="javascript" src="jsdatefuncs.js">
document.write("Included JS file not found"); // (only happens if src doesn't load)
</script>
Feel free to include jsdatefuncs.js in your own web pages or use any of the code. Note that many of the available functions make use of others in the file, so be careful if you only use bits of the code.
// DATE OBJECTS USED ON THIS PAGE
var pcDate = new Date(); // No argument, stores current time (& client timezone offset)
var aDate = new Date("October 09, 1988 13:14:00"); // "Month dd, yyyy hh:mm:ss"
var bDate = new Date("May 26, 2003"); // "Month dd, yyyy"
var cDate = new Date( 1997,08,17,16,22,14 ); // yyyy,mm,dd,hh,mm,ss
var dDate = new Date( 2003,04,26 ); // yyyy,mm,dd
var eDate = new Date( 511111537537 ); // millisecs since midnight 1/1-1970
// Create new Date objects based on intervals from pcDate to demonstrate interval functions
var tempMsecs = nowMillisecs + (68 * 7 * 24 * 60 * 60 * 1000) // pcDate millisecs plus 8 wks
tempMsecs += ( 5 * 24 * 60 * 60 * 1000 ); // plus additional 5 days
var fDate = new Date( tempMsecs );
tempMsecs = nowMillisecs + ( 4 * 24 * 60 * 60 * 1000 ); // pcDate millisecs plus 4 days
tempMsecs += ( 15 * 60 * 60 * 1000 ); // plus additional 15 hours
tempMsecs += ( 9 * 60 * 1000 ); // plus additional 9 minutes
var gDate = new Date( tempMsecs );
tempMsecs = nowMillisecs + ( 38 * 60 * 60 * 1000 ); // pcDate millisecs plus 38 hrs
tempMsecs += ( 4 * 60 * 1000 ); // plus additional 4 mins
tempMsecs += ( 23 * 1000 ); // plus additional 23 secs
var hDate = new Date( tempMsecs );
tempMsecs = nowMillisecs + ( 8 * 60 * 1000 ); // pcDate millisecs plus 8 mins
tempMsecs += ( 33 * 1000 ); // plus additional 33 secs
tempMsecs += ( 7 ); // plus additional 7 msecs
var iDate = new Date( tempMsecs );
// Create a new Date object based on the GMT offset of pcDate
var gmtDate = gmtEquiv( pcDate ); // creates GMT equivalent Date