create. Date and time in standard DBMS format

^date::create[year]
^date::create[
year-month]
^date::create[
year-month-day]
^date::create[
year-month-day hour]
^date::create[
year-month-day hour:minute]
^date::create[
year-month-day hour:minute:second]
^date::create[
year-month-day hour:minute:second.millisecond]
^date::create[
hour:minute]
^date::create[
hour:minute:second]

Creates an object of class
date, containing value of an arbitrary date and/or time accurate to a second. Obligatory parameters are year or hour and minute, while month, day, hour, minute, second and millisecond are optional. If these are not specified, day value will be assigned 1 or current day's value, while hour, minute, and second will be assigned 0.
Note:
millisecond value is ignored.

This feature is useful if you retrieve a date from DB, since the query will return you values of fields with date or time, or both date and time as strings.

Example
# articles created/updated 3 days ago and later are "new"
$new_after[^date::
now(-3)]
$articles[^
table::sql{select id, title, last_update from articles where …}]
^articles.
menu{
    $last_update[^date::create[$articles.last_update]]
    
<a href=${articles.id}.html>$articles.title</a>
    ^if($last_update > $new_after){
new}
    <br />
}

Note for Oracle users: to get date and time in convenient format, specify the format of date and time in server connection string, as recommended in Appendix 3.



Copyright © 1997–2021 Art. Lebedev Studio | http://www.artlebedev.com Last updated: 04.07.2008