In WebSiphon 2, Date and Time values are expressed as specially formatted strings:
time-value | HH:MM:SS AM/PM |
---|---|
date-value | MM/DD/YYYY |
datetime-value | MM/DD/YYYY HH:MM:SS AM/PM |
The functions provided in the built-in Date and Time library are used to:
currentDate ( ) |
Returns: date string | Location: Built-in |
Returns the current date using the server's built-in clock in the format MM/DD/YYYY.
Format this value for display or perform calculations using functions which accept
a date-value as a parameter.
Example: print "Today's date is " currentDate() & "."; >> Today's date is 11/28/2000. See Also: |
currentTime ( ) |
Returns: time string | Location: Built-in |
Returns the current time using the server's built-in clock in the format HH:MM:SS AM/PM. Format this value for display or perform time calculations using functions which accept a time-value as a parameter. Example: print "The current time is " currentTime() & "."; >> The current time is 04:35:28 PM. See Also: |
dayOf ( datetime-value ) |
Returns: integer | Location: Built-in | ||||
Accepts a formatted datetime-value, such as is returned by now(), and returns the day-of-month segment of that value as an integer. Example: the_date = dayOf(now()); print the_date; >> 28 See Also: |
diffTime ( datetime-value1, datetime-value2 ) |
Returns: float | Location: Built-in | ||||||
Returns the difference between two datetime values in seconds. If datetime-value2 is chronologically after datetime-value1, the returned result will be negative. The result is a floating point value in order to gain the greater precision of that data type. The actual value will always be a whole number. The example below illustrates how to compute a rough benchmark of the time required for a template to execute. It then appends the result to WebSiphon's console log window. Compare with the same operation using tickCount() which provides a more precise benchmark. Example: start_time = now(); // This is just an example, the actual contents of your template with // HTML and SiphonScript would go here. elapsed = diffTime(now(), start_time); appendLog(template_uri & " " & (elapsed as float(,2)) & "s exec"); |
formatDate ( date-value, format-string ) |
Returns: string | Location: Built-in | ||||||
Returns the formatted date segment of the date-value parameter using the web server's localized date format setting (as specified on the server computer's OS Control Panel). The format-string parameter may be one of "long", "short", or "abbrev". This function is used to create human-readable content, and should not be used to obtain a date value suitable for use as a paramater to other functions. If a datetime value is provided in date-value, the time segment is ignored. Examples:
See Also: |
formatDateTime (datetime-value, format-string, want-seconds) |
Returns: string | Location: Built-in | ||||||||
Provided a datetime-value, returns a formatted datetime string using the web server's localized datetime format setting (as specified on the server computer's OS Control Panel). The format-string parameter may be one of "long", "short", or "abbrev". The want-seconds boolean indicates whether or not to include the seconds in the returned output. This function is used to create human-readable content, and should not be used to obtain a datetime value suitable for use as a paramater to other functions. Examples:
See Also: |
formatRFC1123 ( datetime-value ) |
Returns: string | Location: Built-in | ||||
Given a datetime-value, first converts to a Greenwich Mean Time (GMT, or UT) value and then returns an RFC1123-formatted datetime string as a result. Note that if you need a datetime string suitable for use as an HTTP cookie expiration value, then you'll need to further modify this value to include dashes within the date as a delimiter. Refer to setCookie()'s documentation for further details. Example: print formatRFC1123("11/03/1997 12:01:15 PM"); >> Mon, 03 Nov 1997 18:01:15 GMT See Also: |
formatTime ( time-value, want-seconds ) |
Returns: string | Location: Built-in | ||||||
Returns the formatted time segment of the time-value parameter using the web server's localized time format setting (as specified on the server computer's OS Control Panel). The want-seconds boolean indicates whether or not to include the seconds in the returned output. This function is used to create human-readable content, and should not be used to obtain a time value suitable for use as a parameter to other functions. If a datetime value is provided in time-value, the date segement is ignored. Examples: print formatTime(currentTime(), true); >> 6:23:07 PM print formatTime(now(), false); >> 6:23 PM See Also: |
formatTimeStr ( datetime-value, format-string ) |
Returns: string | Location: Built-in | ||||||||||||||||||||||||||||||||||||||||||||
For those who need utmost control in formatting datetime values, this very flexible though somewhat cryptic function returns the formatted datetime-value parameter as specified in the format-string. The format parameter may contain any combination of the specifier strings listed in the table below. Valid string specifier tokens for format-string:
Example: print formatTimeStr(now(), "%A, %B %d, %Y %I:%M:%S %p"); >> Friday, September 6, 1996 06:23:07 PM |
hourOf ( time-value ) |
Returns: integer | Location: Built-in | ||||
Returns the hour segment of time-value as an integer. The returned value is based on a 24-hour clock, so values less than 12 are considered AM and values greater than 12 are PM. Example: the_hour = hourOf(now()); print the_hour; >> 14 |
listToTime ( datetime-list ) |
Returns: datetime string | Location: Built-in | ||||||||||||||||||||
Converts a structured list containing the individual datetime fields into a formatted datetime string suitable for passing to other date and time functions (in the format "MM/DD/YYYY HH:MM:SS AM/PM"). The datetime-list parameter is a list with the following structure:
See Also: |
minuteOf ( time-value ) |
Returns: integer | Location: Built-in | ||||
Returns the minute segment of time-value as an integer. Example: the_minute = minuteOf(now()); print the_minute; >> 45 |
monthName ( month-integer ) |
Returns: string | Location: Built-in | ||||
Given a month as a number (1-12) in month-integer, this function will return the actual name of the month using the web server's localized date format setting (as specified on the server computer's OS Control Panel). Example: print monthName(monthOf(now())); >> November See Also: |
monthOf ( time-value ) |
Returns: integer | Location: Built-in | ||||
Returns the month segment of time-value as an integer. Example: the_month = monthOf(now()); print the_month; >> 11 See Also: |
now ( ) |
Returns: datetime string | Location: Built-in |
Returns a string containing the current date and time with seconds, in that order, with a space in between. The format of the returned datetime string is a standard international time string in the format MM/DD/YYYY HH:MM:SS AM/PM. This function returns a datetime value suitable for use as a parameter to other Date and Time functions. Example: print "Right now it is " now() & "."; >> Right now it is 09/03/2000 10:15:23 AM. |
nowSecs ( ) |
Returns: float | Location: Built-in |
Returns the current time in seconds since January 1, 1904. Time values expressed in seconds relative to a common point in time are helpful when you need to compute time values, such as scheduling or expiration logic. See Also: |
secondsOf ( time-value ) |
Returns: integer | Location: Built-in | ||||
Returns the seconds segment of time-value as an integer. Example: the_seconds = secondsOf(now()); print the_seconds; >> 47 |
secsToTime ( time-value-seconds ) |
Returns: string | Location: Built-in | ||||
Converts a time value in seconds since January 1, 1904 to a formatted datetime string suitable for use with any other date and time functions. See Also: |
tickCount ( ) |
Returns: float | Location: Built-in |
Returns the number of ticks (60ths of a second) since the computer was turned on. The tick count value is useful for generating pseudo-random numbers such as session IDs or recording the amount of time needed for a template to execute. Example: start_ticks = tickCount(); // This is just an example, the contents of your template with // HTML and SiphonScript would go here. elapsed = (tickCount() - start_ticks); seconds_elapsed = elapsed / 60; appendLog("This template took " & (seconds_elapsed as float(,2)) & " seconds to execute which is " & elapsed & " ticks."); |
timeToList ( datetime-value ) |
Returns: datetime-list | Location: Built-in | ||||||||||||||||||||||||||
Converts a standard datetime string into a structured list containing the individual time and date fields. This, in conjunction with listToTime(), is a useful method of incrementing or decrementing a time value by a specific amount. The returned datetime-list has the following structure:
See Also: |
timeToSecs ( datetime-value ) |
Returns: float | Location: Built-in | ||||
Converts a standard datetime string to the number of seconds since January 1, 1904, expressed as an integer but returned as a float to gain greater precision affored by the floating point data type. See Also: |
weekDayName ( weekday-number ) |
Returns: string | Location: Built-in | ||||
Given a weekday as a number (1-7) in weekday-number, this function will return the actual name of the weekday using the web server's localized date format setting (as specified on the server computer's OS Control Panel). Example: print weekDayName(weekDayOf(now())); >> Tuesday See Also: |
weekDayOf ( datetime-value ) |
Returns: integer | Location: Built-in | ||||
Returns the week day segment of datetime-value. Rather than returning the actual date as in dayOf(), this function returns the week day number (1 [Sunday] - 7 [Saturday]) as an integer. Example: the_weekday = weekDayOf(now()); print the_weekday; >> 3 See Also: |
yearOf ( datetime-value ) |
Returns: integer | Location: Built-in | ||||
Returns the year segment of datetime-value as an integer. Example: the_year = yearOf(now()); print the_year; >> 1997 |