Option | Description | Arguments | Return Value |
---|---|---|---|
language | An object that contain the language to be used in formatting the output from the print function | N/A | N/A |
Example:
alert(new Date().language.days.short[1]); // will alert Mo (short for Monday) |
|||
daysInMonth | Returns the number of days in the month | N/A | Number of days |
Example:
alert(new Date(2007, 8, 1).daysInMonth()); // will alert 30 (30 days in Septembar) |
|||
isLeapYear | Check if the year is a leap year or not | N/A | Boolean; true if the year is leap, false otherwise. |
Example:
alert(new Date(2008,0,1).isLeapYear()); // will alert true alert(new Date(2009,0,1).isLeapYear()); // will alert false |
|||
fromString | Create a date object from a string | str: see below | A new date object |
str: the string variable for the date. If the date can't be parsed using Date.parse() a list of custom values are provided below.
All custom values are relative to the date object. Possible values:
|
|||
Example:
alert(new Date().fromString("yesterday")); // will alert yesterday's day |
|||
fromObject | Create a date from an object | date_obj: see below | A new date object |
date_obj: is a javascript object (key and value object) and
should have the following attributes
|
|||
Example:
alert(new Date(2007,8,1).fromObject({'date':'last friday'})); // will alert the date for Sep 28th 2007 alert(new Date(2007,8,1).fromObject({'date':'3rd Monday'})); // will alert the date for Sep 17th 2007 |
|||
Returns a formatted date string similar to PHP date function. Please visit http://us.php.net/manual/en/function.date.php for more details on the possible values. The only exception is the Y and o will return the same value |
format: the format of the date.
lang: a language object if using a different language than the date object |
String of the formatted date | |
alert(new Date(2007,8,12).print("D, d M Y")); // will alert Wed, 12 Sep 2007 | |||
getWeekInYear | Returns the number of week in the year | N/A | Number of weeks |
Example:
alert(new Date(2007,8,12).getWeekInYear()); // will alert 36 |
|||
getDayInYear | Returns the number of day in the year | N/A | Number of days |
Example:
alert(new Date(2007,8,12).getDayInYear()); // will alert 253 |
|||
getHourInYear | ~~~~~~~ | N/A | Number of hours |
getMinuteInYear | ~~~~~~~ | N/A | Number of minutes |
getSecondInYear | ~~~~~~~ | N/A | Number of seconds |
getMillisecondInYear | ~~~~~~~ | N/A | Number of milliseconds |
getWeekSince | Returns the number of week since a given date | date: a JavaScript Date | Number of weeks |
Example:
alert(new Date(2007,8,12).getWeekSince(new Date(2006,2,14))); // will alert 78 |
|||
getDaySince | Returns the number of day in the year | date: a JavaScript Date | Number of days |
Example:
alert(new Date(2007,8,12).getDaySince(new Date(2006,2,14))); // will alert 547 |
|||
getHourSince | ~~~~~~~ | ~~~~~~~ | Number of hours |
getMinuteSince | ~~~~~~~ | ~~~~~~~ | Number of minutes |
getSecondSince | ~~~~~~~ | ~~~~~~~ | Number of seconds |
getMillisecondSince | ~~~~~~~ | ~~~~~~~ | Number of milliseconds |
timeDifference | Returns the time difference in milliseconds between the date and the arguments date | date: a JavaScript Date | Difference in milliseconds |
Example:
alert(new Date(2007,8,12).timeDifference(new Date(2006,2,14))); // will alert 47260800000 |
|||
toSwatchInternetTime | Returns the number of beats as a string (including the @ sign)
This function assume the browser handles the time zone and day time saving. For more details about the Swatch Internet Time, please visit http://www.swatch.com/internettime/ |
N/A | beats |
Example:
alert(new Date(2007,8,12,8,52,0).toSwatchInternetTime()); // will alert @702 (based on timezone) |
|||
fromSwatchInternetTime | Returns a JavaScript Date object (approximate time) from the given bean. This function assume the browser handles the time zone and day time saving. For more details about the Swatch Internet Time, please visit http://www.swatch.com/internettime/ |
beat: Swatch Internet Time beat | A new date object |
Example:
alert(new Date().fromSwatchInternetTime(354)); // will alert the time at 10:47:31 (based on timezone) |