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: In addition to 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. This means 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>);
(or)
<result> = toDateTimeString(<input_data>, <dateTimeFormat>, <timeZone>);
where,
Parameter | Data type | Description |
<result> | TEXT | Result that will contain the returned date value. Note:The date-time format and timezone will be converted to the preference specified using <dateTimeFormat> and <timeZone> parameters. |
<input_data> | NUMBER | The data is returned in the specified date-time format or timezone as indicated 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:
|
Learn more about the supported date-time and time formats.
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:
ctime = 1693905560373; // This is a date-time value represented in Unix time format. info toDateTimeString(ctime,"MMM dd, yy 'at' hh:mm:ss z, E","IST"); // Returns Sep 05, 23 at 02:49:20 IST, Tue