| Muhammad Yaseen
To use the formatDateTime () function, you need to have a date time, such as that from utcNow () and pass it into the formatDateTime() function. Then you can create your desired date & time output.
An example of this would be formatDateTime(utcNow(), ‘dddd, MMMM dd, yyyy’). This will produce: Friday, May 07,
2021,
For your reference below is the table in which you find the characters for your Date Time formatted string
Character |
Description |
Example |
“d” |
Day of the month |
1 |
“dd” |
Day of the month but includes the initial 0 |
01 |
“ddd” |
Abbreviated name of the day |
Fri |
“dddd” |
Full name of the day |
Friday |
– |
||
“M” |
Month number |
5 |
“MM” |
Month number but includes the initial 0 |
01 |
“MMM” |
Abbreviated name of the month |
Jun |
“MMMM” |
Full name of the month |
June |
– |
||
“y” |
Year number (last character of the year example using 2021) |
1 |
“yy” |
Year number (last 2 characters of the year example using 2021) |
21 |
“yyy” |
Year number (last 3 characters of the year example using 2021) |
021 |
“yyyy” |
Full year |
2021 |
– |
||
h |
Hour |
1 |
hh |
Hour but includes the initial 0 |
01 |
H |
24 Hour Clock |
4 |
HH |
Hour but includes initial 0 |
04 |
– |
||
m |
Minute (example: 5) |
5 |
mm |
Minute but includes the initial 0 |
05 |
– |
||
s |
Second |
7 |
ss |
Second but includes initial 0 |
07 |
– |
||
t |
AM/PM but only the initial letter |
A |
tt |
AM/PM |
AM |
– |
||
“f” |
The tenths of a second in a date and time value. |
2009-06-15T13:45:30.6170000 -> 6 |
“ff” |
The hundredths of a second in a date and time value. |
2009-06-15T13:45:30.6170000 -> 61 |
“fff” |
The milliseconds in a date and time value. |
6/15/2009 13:45:30.617 -> 617 |
“ffff” |
The ten thousandths of a second in a date and time value. |
2009-06-15T13:45:30.6175000 -> 6175 |
“fffff” |
The hundred thousandths of a second in a date and time value. |
2009-06-15T13:45:30.6175400 -> 61754 |
“ffffff” |
The millionths of a second in a date and time value. |
2009-06-15T13:45:30.6175420 -> 617542 |
“fffffff” |
The ten millionths of a second in a date and time value. |
2009-06-15T13:45:30.6175425 -> 6175425 |
– |
||
“F” |
If non-zero, the tenths of a second in a date and time value. |
2009-06-15T13:45:30.6170000 -> 6 |
“FF” |
If non-zero, the hundredths of a second in a date and time value. |
2009-06-15T13:45:30.6170000 -> 61 |
“FFF” |
If non-zero, the milliseconds in a date and time value. |
2009-06-15T13:45:30.6170000 -> 617 |
“FFFF” |
If non-zero, the ten thousandths of a second in a date and time value. |
2009-06-15T13:45:30.5275000 -> 5275 |
“FFFFF” |
If non-zero, the hundred thousandths of a second in a date and time value. |
2009-06-15T13:45:30.6175400 -> 61754 |
“FFFFFF” |
If non-zero, the millionths of a second in a date and time value. |
2009-06-15T13:45:30.6175420 -> 617542 |
“FFFFFFF” |
If non-zero, the ten millionths of a second in a date and time value. |
2009-06-15T13:45:30.6175425 -> 6175425 |
– |
||
“g”, “gg” |
The period or era. |
2009-06-15T13:45:30.6170000 -> A.D. |
– |
||
“K” |
Time zone information. |
2009-06-15T13:45:30, Kind Utc -> Z |
– |
||
“z” |
Hours offset from UTC, with no leading zeros. |
2009-06-15T13:45:30-07:00 -> -7 |
“zz” |
Hours offset from UTC, with a leading zero for a single-digit value. |
2009-06-15T13:45:30-07:00 -> -07 |
“zzz” |
Hours and minutes offset from UTC. |
2009-06-15T13:45:30-07:00 -> -07:00 |
– |
||
“:”, “.” |
The time separator. |
2009-06-15T13:45:30 -> : (en-US) |
– |
||
“/”, “-“ |
The date separator. |
2009-06-15T13:45:30 -> / (en-US) |
– |
||
“string”, ‘string’ |
Literal string delimiter. |
2009-06-15T13:45:30 (“arr:” h:m t) -> arr: 1:45 P |
– |
||
% |
Defines the following character as a custom format specifier. |
2009-06-15T13:45:30 (%h) -> 1 |
– |
||
\ |
The escape character. |
2009-06-15T13:45:30 (h \h) -> 1 h |
– |
||
Any other character |
The character is copied to the result string unchanged. |
2009-06-15T01:45:30 (arr hh:mm t) -> arr 01:45 A |
Join us next time, as we continue our journey of learning canvas apps.Click here to learn more about Imperium's Power Apps Services. We hope this information was useful, and we look forward to sharing more insights into the Power Platform world.