Open topic with navigation
The DMExpress DateAdd function can be used to convert a UNIX (or POSIX) timestamp to a DateTime value. UNIX timestamps are given in UTC (Universal Coordinated Time), so the converted value will also be in UTC.
The attached example demonstrates how to convert a UNIX (or POSIX) timestamp to a DateTime value.
UNIX time is defined as the number of seconds that have elapsed since Unix Epoch Time, which is midnight Coordinated Universal Time (UTC), 1 January 1970.
The example task defines the following values:
||represents Unix Epoch Time as a DateTime value using the ToDate function|
||converts a given UNIX timestamp to a DateTime value by adding the UNIX time (whose unit is seconds) to the UNIX_Epoch_Time using the DateAdd function|
For example, given an input Unix time of 1362612890, the value of UNIX_To_DateTime would be 2013-03-06 23:34:50 (in UTC).
The format of the DateTime value obtained from the conversion can be changed by changing the date mask of the value UNIX_Epoch_Time. If you want to convert the DateTime value to your local time zone, you would need to add/subtract the appropriate number of hours relative to UTC.
177_ConvertUnixTimeToDateTime.zip, compatible with DMExpress version 7.6 or higher
For additional information on the ToDate and DateAdd functions, and date masks, see ToDate function, DateAdd function, and Syntax of date pattern in the DMExpress Help.
Copyright © 2016 Syncsort All rights reserved.