w3Utils Reference

Reference

w3 DateUtils


 w3.DateUtils
    DateTimeToGMT( dDate ) : String
    FormatDateTime( Mask, dDate ) : String
    GetGMTOffset() : Integer
    GetTimeZone() : String
    GMTToDateTime( szGMTDateString ) : DateTime
    IncDay( dtDate, dwCount ) : DateTime
    IncMonth( dtDate, dwCount ) : DateTime
    IncWeek( dtDate, dwCount ) : DateTime
    IncYear( dtDate, dwCount ) : DateTime
    WeekByDate( dtDate ) : Byte


Methods

  DateTimeToGMT(dDate) : 
Converts a dateTime to a GMT string
var aDate = new Date();
var gmtDate = DateUtils.DateTimeToGMT( aDate.getVarDate() );

// gmtDate gets something like: 'Tue, 8 Dec 1998 09:59:16 +0100'
  FormatDateTime(Mask, dDate) : 
Formats a dateTime using a user defined mask.
var dateFormatted = DateUtils.FormatDateTime( "yyyy-mm-dd hh:mm",  aDate.getVarDate() );

// note usage of getVarDate()
  GetGMTOffset() : 
Returns the offset from GMT
var gmtOffset = DateUtils.GetGMTOffset();
  GetTimeZone() : 
Returns the 'name' of the current timezone


var timeZone = DateUtils.GetTimeZone();

// returns '+0100' for example
  GMTToDateTime(szGMTDateString) : 
Converts a GMT string to DateTime
var aDateTime = DateUtils.GMTToDateTime( gmtDate );

// returns something like: '12/8/98 10:02:30 AM'
  IncDay(dtDate, dwCount) : 
Increases the given date (dtDate) with dwCount number of days
var aDate = new Date();
var inTwoDays = new Date( DateUtils.IncDay( aDate.getVarDate(), 2 ) );

// note the usage of getVarDate()
  IncMonth(dtDate, dwCount) : 
Increases the given date (dtDate) with dwCount number of months
var aDate = new Date();
var inTwoMonths = new Date( DateUtils.IncMonth( aDate.getVarDate(), 2 ) );

// note the usage of getVarDate()
  IncWeek(dtDate, dwCount) : 
Increases the given date (dtDate) with dwCount number of weeks
var aDate = new Date();
var inTwoWeeks = new Date( DateUtils.IncWeek( aDate.getVarDate(), 2 ) );

// note the usage of getVarDate()
  IncYear(dtDate, dwCount) : 
Increases the given date (dtDate) with dwCount number of years
var aDate = new Date();
var inTwoYears = new Date( DateUtils.IncYear( aDate.getVarDate(), 2 ) );

// note the usage of getVarDate()
  WeekByDate(dtDate) : 
Returns the week number given a date.

Using the week number is very common for planning purposes in for example Sweden, whereas it is virtually a nonexistant practice in the US. This can be seen in the absence of week numbering in US calendars and the usage of such nunbering in Swedish calendars.
var aDate = new Date();
var theWeek = DateUtils.WeekByDate( aDate.getVarDate() );

// note the usage of getVarDate()