toDateTimeString
Table of Contents
Note:The toDateTimeString built-in function is applicable to all Zoho services.
Overview
The toDateTimeString function is a built-in function used for managing date and time data efficiently. Primarily, this function is used to handle Unix time conversion, simplifying the process of working with timestamps in Unix-based systems.
- Date Format format: Apart from converting Unix time, this function can also adjust input date-time values to various accepted date-time formats, enhancing compatibility with diverse date representations.
- Timezone: Additionally, the toDateTimeString function enables seamless conversion of dates and times between different time zones. This capability guarantees consistent handling of time-related data, a critical necessity for globally used or distributed applications.
Note:
- Daylight saving is taken into account by default wherever required. i.e., the returned date will be automatically adjusted for DST.
- The output(for example, month, timezone or day) is in English for all users, regardless of their locale.
Return Type
- TEXT
Syntax
<result> = <input_data>.toDateTimeString(<dateTimeFormat>, <timeZone>);
<result> = toDateTimeString(<input_data>, <dateTimeFormat>, <timeZone>);
where,
Parameter | Data type | Description |
<result> | TEXT | result which will contain the returned date value. |
<input_data> | NUMBER | The data is reverted in the date-time format or timezone that is mentioned in the input. Note:
|
<dateTimeFormat> | TEXT | The format in which the date time value will be returned. Note:
|
<timeZone> | TEXT | Time zone in which the date-time value will be returned. Note:
|
Applicable Date-Time Literals
Letter | Date and Time Component |
G | Era designator |
y | Calendar year Examples: y - 2019 yy -19 yyy - 2019 dateValue = '29-Dec-2019'; |
Y | Week year Examples: Y - 2019 YY -19 YYY - 2019 dateValue = '29-Dec-2019'; |
M | Month in year Examples: M - 1 MM - 01 MMM - Jan |
w | Week in year |
W | Week in month |
D | Day in year |
d | Day in month |
F | Day of week in month |
E | Day name in week Examples: E - Tue EEEE - Tuesday |
u | Day number of week |
a | am/pm marker |
H | Hour in day (0-23) |
k | Hour in day (1-24) |
K | Hour in am/pm (0-11) |
h | Hour in am/pm (1-12) |
m | Minute in hour |
s | Second in minute |
S | Millisecond |
z | General time zone |
Z | RFC time zone |
X | ISO 8601 time zone |
Examples
Here is an example of how the toDateTimeString can be used:
Note: This example is provided with the assumption that the user's timezone is set to 'Asia/Kolkata.'
The outputs may vary if tested with different time zones.
ctime=1693905560373; info toDateTimeString(ctime,"MMM dd, yy 'at' hh:mm:ss z, E","IST"); // Returns Sep 05, 23 at 02:49:20 IST, Tue