Classic ASP Framework
org.classicasp.primitive.DateTimeEx

The DateTimeEx class represents date and time information. The DateTimeEx class lets you retrieve date and time values relative to universal time or relative to local time.

To create a DateTimeEx object, you can use the constructor or the global function, or assign a literal value.

Example

	
  Response.Write DateTimeEx("").add("yyyy", 1).add("m", 1).add("d", -1).toJSON()
  

Output

"2013-10-24 16:20:10"

Summary

Adds a specified interval to a date and returns a DateTimeEx object.
Gets the difference between two dates as a specified interval and returns a NumberEx object.
Returns the value in a specific format.
Returns a Bencoded string representation of the object.
Returns the value in a timestamp format .
Returns a json encoded string representation of the object.
Returns the value in a timestamp format .
Returns a string representation of the object.
Returns the value in a timestamp format .
Returns the value in a timestamp format .
Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).
Returns an XML encoded string representation of the object.
Writes a json encoded string representation of the object.
Writes an XML encoded string representation of the object.

add

Public Function add(
ByRef vInputInterval,
ByRef vInputValue)
Adds a specified interval to a date and returns a DateTimeEx object.

Input Interval

  • yyyy - Year
  • q - Quarter
  • m - Month
  • y - Day of year
  • d - Day
  • w - Weekday
  • ww - Week of year
  • h - Hour
  • n - Minute
  • s - Second

Returns

DateTimeEx

Example

		
	  Response.Write DateTimeEx("").add("d", 1).toJSON()
	  

Output

"2012-09-25 23:39:25"

difference

Public Function difference(
ByRef vInputInterval,
ByRef vInputValue)
Gets the difference between two dates as a specified interval and returns a NumberEx object.

Input Interval

  • yyyy - Year
  • q - Quarter
  • m - Month
  • y - Day of year
  • d - Day
  • w - Weekday
  • ww - Week of year
  • h - Hour
  • n - Minute
  • s - Second

Returns

NumberEx

Example

		
	  Response.Write DateTimeEx("").difference("d", "2012-01-01").toJSON()
	  

Output

-268

format

Public Function format(ByVal sFormat)
Returns the value in a specific format.

dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format www.mikesdotnetting.com/Article/22/Date-formatting-in-VBScript

  • %a Abbreviated weekday name (Sun..Sat)
  • %b Abbreviated month name (Jan..Dec)
  • %c Month, numeric (0..12)
  • %D Day of the month with English suffix (0th, 1st, 2nd, 3rd, …)
  • %d Day of the month, numeric (00..31)
  • %e Day of the month, numeric (0..31)
  • %f Microseconds (000000..999999)
  • %H Hour (00..23)
  • %h Hour (01..12)
  • %I Hour (01..12)
  • %i Minutes, numeric (00..59)
  • %j Day of year (001..366)
  • %k Hour (0..23)
  • %l Hour (1..12)
  • %M Month name (January..December)
  • %m Month, numeric (00..12)
  • %p AM or PM
  • %r Time, 12-hour (hh:mm:ss followed by AM or PM)
  • %S Seconds (00..59)
  • %s Seconds (00..59)
  • %T Time, 24-hour (hh:mm:ss)
  • %U Week (00..53), where Sunday is the first day of the week
  • %u Week (00..53), where Monday is the first day of the week
  • %V Week (01..53), where Sunday is the first day of the week; used with %X
  • %v Week (01..53), where Monday is the first day of the week; used with %x
  • %W Weekday name (Sunday..Saturday)
  • %w Day of the week (0=Sunday..6=Saturday)
  • %X Year for the week where Sunday is the first day of the week, numeric, four digits; used with %V
  • %x Year for the week, where Monday is the first day of the week, numeric, four digits; used with %v
  • %Y Year, numeric, four digits
  • %y Year, numeric (two digits)
  • %% A literal “%” character
  • %x x, for any “x” not listed above

Returns

StringEx

toBencode

Public Function toBencode()
Returns a Bencoded string representation of the object.

Returns

String

Example

		
	  Response.Write DateTimeEx("").toBencode()
	  

Output

19:2012-09-24 23:37:47

toDate

Public Function toDate()
Returns the value in a timestamp format.

Returns

StringEx

Example

		
	  Response.Write DateTimeEx("").toDate().toJSON()
	  

Output

"2012-09-25"

toJSON

Public Function toJSON()
Returns a json encoded string representation of the object.

Returns

String

Example

		
	  Response.Write DateTimeEx("").toJSON()
	  

Output

"2012-09-24 23:39:25"

toRFC822

Public Function toRFC822(ByVal vInputOffset)
Returns the value in a timestamp format.

Returns

StringEx

Example

		
	  Response.Write DateTimeEx("").toRFC822("").toJSON()
	  

Output

"Tue, 25 Sep 2012 00:17:25 +0000"

toString

Public Function toString()
Returns a string representation of the object.

Returns

StringEx

toTime

Public Function toTime()
Returns the value in a timestamp format.

Returns

StringEx

Example

		
	  Response.Write DateTimeEx("").toTime().toJSON()
	  

Output

"23:39:25"

toTimestamp

Public Function toTimestamp()
Returns the value in a timestamp format.

Returns

StringEx

Example

		
	  Response.Write DateTimeEx("").toTimestamp().toJSON()
	  

Output

"2012-09-25 23:39:25"

toUnixEpoch

Public Function toUnixEpoch()
Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).

Returns

NumberEx

toXML

Public Function toXML()
Returns an XML encoded string representation of the object.

Returns

String

Example

		
	  Response.Write DateTimeEx("").toXML()
	  

Output

<data type="Date">2012-09-24 23:40:46</data>

writeJSON

Public Sub writeJSON()
Writes a json encoded string representation of the object.

Returns

N/A

Example

		
	  Call DateTimeEx("").writeJSON()
	  

Output

"2012-09-24 23:39:25"

writeXML

Public Sub writeXML()
Writes an XML encoded string representation of the object.

Returns

N/A

Example

		
	  Call DateTimeEx("").writeXML()
	  

Output

<data type="Date">2012-09-24 23:40:46</data>

'***ClassicASP.org
'Copyright 2010 ClassicASP.org

'This file is part of ClassicASP Framework.

'ClassicASP-Framework is free software: you can redistribute it and/or modify
'it under the terms of the GNU General Public License as published by
'the Free Software Foundation, version 3 of the License.

'ClassicASP-Framework is distributed in the hope that it will be useful,
'but WITHOUT ANY WARRANTY; without even the implied warranty of
'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
'GNU General Public License for more details.

'You should have received a copy of the GNU General Public License
'along with ClassicASP-Framework. If not, see .

'For additional information please visit .