P
ROTOTYPE
I'm Not Only The Prototype, I'm Also A Member.
home
▪
stats
▪
search
▪
linkback
▪
about
▪
FAQ
| user: guest,
login
,
register
Date
:
Get first day of Date instance's month (returns name or number)
author:
orangechicken
[+]
,
Submitted: 10.28.02 10p
• Last Edit: 10.28.02 10p
/* Supporting prototypes */ Date.dayNames = [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ]; Date.prototype.getDayName = function() { return Date.dayNames[ this.getDay() ]; } /* getFirstDayOfMonth - returns number or name of first day of Date instance's month */ Date.prototype.getFirstDayOfMonth = function( useName ) { var tempDate = new Date( this.getFullYear(), this.getMonth() ); return ( !useName ) ? tempDate.getDay() : tempDate.getDayName(); };
usage
myDate = new Date(); trace( myDate.getFirstDayOfMonth() ); // output: 2 trace( myDate.getFirstDayOfMonth( true )); // output: Tuesday
Add Comment
[+]
›opyleft 2001-2010. Layer51 is: Jaime Prado.
@