0
milliseconds, epoch time, today's date

/t5/coldfusion-discussions/milliseconds-epoch-time-today-s-date/td-p/365344
May 26, 2008
May 26, 2008
Copy link to clipboard
Copied
Hello:
1210921200000 is the number of milliseconds from Jan 1 1970 to a certain date/time. How do I convert that into a date/time using CF? I am sure somebody has faced this before. Thanks
1210921200000 is the number of milliseconds from Jan 1 1970 to a certain date/time. How do I convert that into a date/time using CF? I am sure somebody has faced this before. Thanks
TOPICS
Advanced techniques
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/milliseconds-epoch-time-today-s-date/m-p/365345#M32789
May 26, 2008
May 26, 2008
Copy link to clipboard
Copied
one way, off the top of my head, would be:
dateadd('s', 1210921200000/1000, createdatetime(1970, 1, 1, 0, 0, 0))
there are other ways. experiment with different cf date/time functions.
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
dateadd('s', 1210921200000/1000, createdatetime(1970, 1, 1, 0, 0, 0))
there are other ways. experiment with different cf date/time functions.
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

Guest
AUTHOR
/t5/coldfusion-discussions/milliseconds-epoch-time-today-s-date/m-p/365347#M32791
May 27, 2008
May 27, 2008
Copy link to clipboard
Copied
Azadi: You reply worked perfectly well. Thanks a ton.
<CFSET a = dateadd('s', #encounter_date#/1000, createdatetime(1970, 1, 1, 0, 0, 0))>
<CFSET a = dateadd('s', #encounter_date#/1000, createdatetime(1970, 1, 1, 0, 0, 0))>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/milliseconds-epoch-time-today-s-date/m-p/365346#M32790
May 27, 2008
May 27, 2008
Copy link to clipboard
Copied
worldnet5 wrote:
> Hello: 1210921200000 is the number of milliseconds from Jan 1 1970 to a
> certain date/time. How do I convert that into a date/time using CF? I am sure
> somebody has faced this before. Thanks
preserves the accuracy of the original epoch offset:
<cfscript>
aDate=createObject("java","java.util.Date").init(javacast("long",1210921200000));
writeOutput("#dateFormat(aDate)# #timeFormat(aDate)#");
</cfscript>
be aware that the datetime returned from this will be in the *server* timezone
*not* UTC.
> Hello: 1210921200000 is the number of milliseconds from Jan 1 1970 to a
> certain date/time. How do I convert that into a date/time using CF? I am sure
> somebody has faced this before. Thanks
preserves the accuracy of the original epoch offset:
<cfscript>
aDate=createObject("java","java.util.Date").init(javacast("long",1210921200000));
writeOutput("#dateFormat(aDate)# #timeFormat(aDate)#");
</cfscript>
be aware that the datetime returned from this will be in the *server* timezone
*not* UTC.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Beginner
,
/t5/coldfusion-discussions/milliseconds-epoch-time-today-s-date/m-p/365348#M32792
Oct 30, 2018
Oct 30, 2018
Copy link to clipboard
Copied
<cfscript>
CreateObject("java", "java.util.Date").from( CreateObject("java", "java.time.Instant").ofEpochMilli(JavaCast("long", 1210921200000)) )
</cfscript>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Explorer
,
LATEST
/t5/coldfusion-discussions/milliseconds-epoch-time-today-s-date/m-p/11278704#M185916
Jul 10, 2020
Jul 10, 2020
Copy link to clipboard
Copied
I know this is from a while ago, but I am working with some covid data coming out of a JSON string
{"OBJECTID":1,"COVID_Date":1584057600000,"Daily_Case_Count":2,"Cumulative_Case_Count":2,"Daily_Death_Count":0,"Cumulative_Death_Count":0,"UTC_Date":1584079200000}}
and the gross number: 1584079200000 was giving me fits!
Your string allowed me to return the right number: dateadd('s', 1584079200000/1000, createdatetime(1970, 1, 1, 0, 0, 0))
output:{ts '2020-03-13 06:00:00'}
Thanks for saving my butt!
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

