Difference between revisions of "STRFTIME()"

From Recital Documentation Wiki
Jump to: navigation, search
 
(16 intermediate revisions by one user not shown)
Line 1: Line 1:
{{YLM to do}}
 
 
 
==Purpose==
 
==Purpose==
 
+
Return a character string including a formatted date or datetime string
  
  
Line 10: Line 8:
  
 
==See Also==
 
==See Also==
 
+
[[AMPM()]], [[CDOW()]], [[CMONTH()]], [[CTOD()]], [[CTOT()]], [[DATE()]], [[DATETIME()]], [[DAY()]], [[DAYS()]], [[DOW()]], [[DTOC()]], [[DTOM()]], [[DTOS()]], [[DTOV()]], [[ELAPTIME()]], [[EMPTY()]], [[EPOCH()]], [[GOMONTH()]], [[HOUR()]], [[HOURS()]], [[LTOS()]], [[MDY()]], [[MINUTE()]], [[MINUTES()]], [[MONTH()]], [[MTOD()]], [[MTOS()]], [[QUARTER()]], [[SEC()]], [[SECONDS()]], [[SECS()]], [[SET CENTURY]], [[SET DATE]], [[SET EPOCH]], [[SET HOURS]], [[SET MARK]], [[SET SECONDS]], [[SET VAXTIME]], [[STOD()]], [[STR()]], [[TIME()]], [[TIMESTAMP()]], [[TSTRING()]], [[TTOC()]], [[TTOD()]], [[TYPE()]], [[VAL()]], [[VALIDTIME()]], [[VTOD()]], [[WEEK()]], [[YEAR()]]
  
  
 
==Description==
 
==Description==
 
+
The STRFTIME() function returns a character string including a date or datetime string formatted according to <expC1>.  The <expC1> string may include any of the format elements from the table below.  The optional <expC2> is a date or datetime in string format.  If <expC2> is not specified, the current system date and time are assumed.
  
  
 
{| class="wikitable"
 
{| class="wikitable"
!Format Element||Description
+
!Format Element||Description||Example value
 
|-
 
|-
| Day||
+
|'''Day'''||||
 
|-
 
|-
| %A||
+
|%a||Abbreviated character day of the week||''Sun'' - ''Sat''
 
|-
 
|-
| %A||
+
|%A||Character day of the week||''Sunday'' - ''Saturday''
 
|-
 
|-
| %d||
+
|%d||Day of the month (two digits with leading zero)||''01'' to ''31''
 
|-
 
|-
| %e||
+
|%e||Day of the month (space precedes single digits)||'' 1'' - ''31''
 
|-
 
|-
| %j||
+
|%j||Day of the year (three digits with leading zeros)||''001'' - ''366''
 
|-
 
|-
| %u||
+
|%u||ISO-8601 numeric day of the week||''1'' (Monday) - ''7'' (Sunday)
 
|-
 
|-
| %w||
+
|%w||Numeric day of the week||''0'' (Sunday) - ''6'' (Saturday)
 
|-
 
|-
| Week||
+
|'''Week'''||||
 
|-
 
|-
| %U||
+
|%U||Week of the year: week 01 starts from the first Sunday||''00'' - ''53''
 
|-
 
|-
| %V||
+
|%V||ISO-8601 week of the year: week 01 is the first week with at least 4 weekdays, Monday start||''01'' to ''53''
 
|-
 
|-
| %W||
+
|%W||Week of the year: week 01 starts from the first Monday||''00'' - ''53''
 
|-
 
|-
| Month||
+
|'''Month'''||||
 
|-
 
|-
| %b||
+
|%b||Abbreviated month||''Jan'' - ''Dec''
 
|-
 
|-
| %B||
+
|%B||Month||''January'' - ''December''
 
|-
 
|-
| %h||
+
|%h||Abbreviated month||''Jan'' - ''Dec''
 
|-
 
|-
| %m||
+
|%m||Month (two digits with leading zero)||''01'' to ''12''
 
|-
 
|-
| Year||
+
|'''Year'''||||
 
|-
 
|-
| %C||
+
|%C||Century||''19'' (1900 - 1999) - ''20'' (2000 - 2037)
 
|-
 
|-
| %g||
+
|%g||ISO-8601 two digit year: week 01 is the first week with at least 4 weekdays, Monday start||''00'' - ''99''
 
|-
 
|-
| %G||
+
|%G||ISO-8601 four digit year: week 01 is the first week with at least 4 weekdays, Monday start||''1902'' - ''2037''
 
|-
 
|-
| %y||
+
|%y||Two digit year||''00'' - ''99''
 
|-
 
|-
| %Y||
+
|%Y||Four digit year||''1902'' - ''2037''
 
|-
 
|-
| Time||
+
|'''Time'''||||
 
|-
 
|-
| %H||
+
|%H||Two digit hour in 24 hour format||''00'' - ''23''
 
|-
 
|-
| %I||
+
|%I||Two digit hour in 12 hour format||''01'' - ''12''
 
|-
 
|-
| %l||
+
|%l||Two digit hour in 12 hour format (space precedes single digits)||'' 1'' - ''12''
 
|-
 
|-
| %M||
+
|%M||Two digit minutes||''00'' - ''59''
 
|-
 
|-
| %p||
+
|%p||Upper-case AM or PM||''AM'' or ''PM''
 
|-
 
|-
| %P||
+
|%P||Lower-case AM or PM||''am'' or ''pm''
 
|-
 
|-
| %r||
+
|%r||Equivalent of "%I:%M:%S %p"||e.g. ''01:26:04 PM''
 
|-
 
|-
| %R||
+
|%R||Equivalent of "%H:%M"||e.g. ''13:26''
 
|-
 
|-
| %S||
+
|%S||Two digit seconds||''00'' - ''59''
 
|-
 
|-
| %T||
+
|%T||Equivalent of "%H:%M:S%"||e.g. ''13:26:04''
 
|-
 
|-
| %X||
+
|%X||Time based on locale preference||e.g. ''01:26:04'' or ''13:26:04''
 
|-
 
|-
| %z||
+
|%z||Time-zone||e.g. ''GMT'' or ''+0000''
 
|-
 
|-
| %Z||
+
|%Z||Time-zone alternative format||e.g. ''+0000'' or ''GMT''
 
|-
 
|-
| Time and Date Stamps||
+
|'''Time and Date Stamps'''||||
 
|-
 
|-
| %c||
+
|%c||Date and time based on locale preference||e.g. ''Mon Nov 30 01:26:04 2009''
 
|-
 
|-
| %D||
+
|%D||Equivalent of "%m/%d/%y"||e.g. ''11/30/09''
 
|-
 
|-
| %F||
+
|%F||Equivalent of "%Y-%m-%d"||e.g. ''2009-11-30''
 
|-
 
|-
| %s||
+
|%s||UNIX Epoch Time timestamp||e.g. ''1259587564'' for ''11/30/2009 01:26:04 PM''
 
|-
 
|-
| %x||
+
|%x||Date based on locale preference||e.g. ''11/30/09''
 
|-
 
|-
| Miscellaneous||
+
|'''Miscellaneous'''||||
 
|-
 
|-
| %n%D||
+
|%n||New line character||
 
|-
 
|-
| %t%D||
+
|%t||Tab character||
 
|-
 
|-
| %%%D%%%n%n||
+
|%%||''%'' character||
 
|-
 
|-
 
|}
 
|}
Line 120: Line 118:
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
 
+
echo strftime("%c",ttoc(datetime()))
 +
echo strftime("%U",dtoc(date()))
 
</code>
 
</code>
  
Line 128: Line 127:
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Functions]]
 
[[Category:Functions]]
[[Category:Array Processing]]
+
[[Category:Date and Time Data]]
[[Category:Array Processing Functions]]
+
[[Category:Date and Time Data Functions]]

Latest revision as of 14:46, 30 November 2009

Purpose

Return a character string including a formatted date or datetime string


Syntax

STRFTIME(<expC1> [, <expC2> ])


See Also

AMPM(), CDOW(), CMONTH(), CTOD(), CTOT(), DATE(), DATETIME(), DAY(), DAYS(), DOW(), DTOC(), DTOM(), DTOS(), DTOV(), ELAPTIME(), EMPTY(), EPOCH(), GOMONTH(), HOUR(), HOURS(), LTOS(), MDY(), MINUTE(), MINUTES(), MONTH(), MTOD(), MTOS(), QUARTER(), SEC(), SECONDS(), SECS(), SET CENTURY, SET DATE, SET EPOCH, SET HOURS, SET MARK, SET SECONDS, SET VAXTIME, STOD(), STR(), TIME(), TIMESTAMP(), TSTRING(), TTOC(), TTOD(), TYPE(), VAL(), VALIDTIME(), VTOD(), WEEK(), YEAR()


Description

The STRFTIME() function returns a character string including a date or datetime string formatted according to <expC1>. The <expC1> string may include any of the format elements from the table below. The optional <expC2> is a date or datetime in string format. If <expC2> is not specified, the current system date and time are assumed.


Format Element Description Example value
Day
%a Abbreviated character day of the week Sun - Sat
%A Character day of the week Sunday - Saturday
%d Day of the month (two digits with leading zero) 01 to 31
%e Day of the month (space precedes single digits) 1 - 31
%j Day of the year (three digits with leading zeros) 001 - 366
%u ISO-8601 numeric day of the week 1 (Monday) - 7 (Sunday)
%w Numeric day of the week 0 (Sunday) - 6 (Saturday)
Week
%U Week of the year: week 01 starts from the first Sunday 00 - 53
%V ISO-8601 week of the year: week 01 is the first week with at least 4 weekdays, Monday start 01 to 53
%W Week of the year: week 01 starts from the first Monday 00 - 53
Month
%b Abbreviated month Jan - Dec
%B Month January - December
%h Abbreviated month Jan - Dec
%m Month (two digits with leading zero) 01 to 12
Year
%C Century 19 (1900 - 1999) - 20 (2000 - 2037)
%g ISO-8601 two digit year: week 01 is the first week with at least 4 weekdays, Monday start 00 - 99
%G ISO-8601 four digit year: week 01 is the first week with at least 4 weekdays, Monday start 1902 - 2037
%y Two digit year 00 - 99
%Y Four digit year 1902 - 2037
Time
%H Two digit hour in 24 hour format 00 - 23
%I Two digit hour in 12 hour format 01 - 12
%l Two digit hour in 12 hour format (space precedes single digits) 1 - 12
%M Two digit minutes 00 - 59
%p Upper-case AM or PM AM or PM
%P Lower-case AM or PM am or pm
%r Equivalent of "%I:%M:%S %p" e.g. 01:26:04 PM
%R Equivalent of "%H:%M" e.g. 13:26
%S Two digit seconds 00 - 59
%T Equivalent of "%H:%M:S%" e.g. 13:26:04
%X Time based on locale preference e.g. 01:26:04 or 13:26:04
%z Time-zone e.g. GMT or +0000
%Z Time-zone alternative format e.g. +0000 or GMT
Time and Date Stamps
%c Date and time based on locale preference e.g. Mon Nov 30 01:26:04 2009
%D Equivalent of "%m/%d/%y" e.g. 11/30/09
%F Equivalent of "%Y-%m-%d" e.g. 2009-11-30
%s UNIX Epoch Time timestamp e.g. 1259587564 for 11/30/2009 01:26:04 PM
%x Date based on locale preference e.g. 11/30/09
Miscellaneous
%n New line character
%t Tab character
%% % character


Example

echo strftime("%c",ttoc(datetime()))
echo strftime("%U",dtoc(date()))


Products

Recital, Recital Server