Function dateFormat()
converts a time value to a string in the specified format and returns that string.
Arguments:
- Time <datetime | timestamp | string>
- Format <string>
Returns:
- Time string <string>
Code of format:
Code | Description | Example |
---|---|---|
%a | Abbreviated name of day of week in system language | (en_US) Sun, Mon, ... |
%A | Full name of day of week in system language | (en_US) Sunday, Monday, ... |
%b | Abbreviated name of month in system language | (en_US) Jan, Feb, ... |
%B | Full name of month in system language | (en_US) January, February, ... |
%c | Default date and time format in the system settings | 'Wed Jan 11 10:59:28 2023' |
%C | Number denoting century (year divided by 100) | 00, 01, ..., 99 |
%d | Day of month (zero-padded) | 01, 02, ..., 31 |
%D | Alternative code of %m/%d/%y |
'01/11/23' |
%e | Day of month | 1, 2, ..., 31 |
%Ez | Time zone | '+08:00' |
%g | Year in 2 digits (without century) | 00, 01, ..., 99 |
%G | Year in 4 digits | 0000, 0001, ..., 9999 |
%h | Alternative code of %b |
See example of %b |
%H | Hour of 24-hour clock (zero-padded) | 00, 01, ..., 23 |
%I | Hour of 12-hour clock (zero-padded) | 01, 02, ..., 12 |
%j | Day of year (zero-padded) | 001, 002, ..., 366 |
%m | Code of month (zero-padded) | 01, 02, ..., 12 |
%M | Minute (zero-padded) | 00, 01, ..., 59 |
%n | Line break | |
%p | AM or PM | (en_US) AM, PM |
%P | am or pm | (en_US) am, pm |
%r | Alternative code of %I/%M/%S %p |
'01:49:23 AM' |
%R | Alternative code of %H:%M |
'13:49' |
%S | Second (zero-padded) | 00, 01, ..., 59 |
%t | Tab | |
%T | Alternative code of %H:%M:%S |
'23:02:05' |
%u | Code of day of week, where 1 stands for Monday ( or 1 for Sunday in a Sun Solaris system | |
%U | Week of year (zero-padded) with the first Sunday being the first day of the week 01 | 00, 01, ..., 53 |
%V | Week of year (zero-padded) with the first day till the first Sunday being week 01 if they have no less than 4 days, or being the last week of the previous year if less than 4 days | 01, 02, ..., 53 |
%W | Week of year (zero-padded) with the first Monday being the first day of the week 01 | 00, 01, ..., 53 |
%w | Code of day of week, where 0 stands for Sunday | 0, 1, ..., 6 |
%x | Default date format in the system settings | '01/11/23' |
%X | Default time format in the system settings | '06:38:45' |
%y | Alternative code of %g |
See example of %g |
%Y | Alternative code of %G |
See example of %G |
%z | UTC offset in the form ±HHMM[SS] | +0000, -0400, +1030, ... |
%Z | Time zone name | GMT, UTC, IST, CST, ... |
%% | Character % | % |
Constant
Example: Convert "2020-01-02 00:05:32" to 'yy-mm-dd hh:mm' format
return dateFormat("2020-01-02 00:05:32", "%y-%m-%d %R")
Function
Example: Convert current system time to 'yyyy/mm/dd' format with AM/PM
return dateFormat(now(), "%Y/%m/%d %r")
Alias
Example: Find 10 @trasnfer
edges, return the time zone of the transfer time
find().edges({@transfer}) as e
limit 10
return dateFormat(e.time, "%Ez")
Property
Example: Find 10 @transfer
edges with their transfer time on weekend
find().edges({dateFormat(@transfer.time, "%w") in [0, 6]}) as e
limit 10
return e{*}