Skip to main content
Known Participant
April 15, 2008
Answered

UNIX timestamp

  • April 15, 2008
  • 1 reply
  • 1234 views
I'm looking for a way to convert a UNIX time value (1201900638) so that it outputs to a ColdFusion page in the mm/dd/yyyy format. Would anyone be able to help with that? Thanks...
This topic has been closed for replies.
Correct answer paross1
According to Unix time the number of seconds elapsed since midnight Coordinated Universal Time (UTC) of January 1, 1970, not counting leap seconds......The Unix time number is zero at the Unix epoch, and increases by exactly 86 400 per day since the epoch

Therefore, 01-JAN-1970 + (1201900638 / 86400) = 01-FEB-2008

Is this the date that equates to the "UNIX time" number that you posted?

According to unix timestamp and epoch conversion tool, 1201900638 equates to the following:

GMT: Fri, 1 Feb 2008 21:17:18 UTC
Your timezone (PDT): Friday, February 01, 2008 1:17:18 PM


Try this:

#DateConvert("utc2Local", DateAdd("s", 1201900638, CreateDate("1970","01","01")))#

Where CreateDate() converts January 01, 1970 to a date/time, DateAdd() with an "s" parameter adds 1201900638 seconds to the "epoch" start date, and DateConvert() with "utc2Local" converts the UTC time to your local time.

You can then use DateFormat() to display it in any format that you desire.
Phil

1 reply

paross1Correct answer
Participating Frequently
April 15, 2008
According to Unix time the number of seconds elapsed since midnight Coordinated Universal Time (UTC) of January 1, 1970, not counting leap seconds......The Unix time number is zero at the Unix epoch, and increases by exactly 86 400 per day since the epoch

Therefore, 01-JAN-1970 + (1201900638 / 86400) = 01-FEB-2008

Is this the date that equates to the "UNIX time" number that you posted?

According to unix timestamp and epoch conversion tool, 1201900638 equates to the following:

GMT: Fri, 1 Feb 2008 21:17:18 UTC
Your timezone (PDT): Friday, February 01, 2008 1:17:18 PM


Try this:

#DateConvert("utc2Local", DateAdd("s", 1201900638, CreateDate("1970","01","01")))#

Where CreateDate() converts January 01, 1970 to a date/time, DateAdd() with an "s" parameter adds 1201900638 seconds to the "epoch" start date, and DateConvert() with "utc2Local" converts the UTC time to your local time.

You can then use DateFormat() to display it in any format that you desire.
Phil