function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
pradyprady 

Unixtimestamp value for an salesforce date

Hi,

 

How can i get the unixtimestamp value of a date from salesforce?

 

I need to pass the date value as unixtimestamp to flot graph library.

 

thanks

Prady

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

By unix timestamp, do you mean milliseconds since the epoch (1/1/1970)?

 

If so, use the DateTime.getTime() method

All Answers

bob_buzzardbob_buzzard

By unix timestamp, do you mean milliseconds since the epoch (1/1/1970)?

 

If so, use the DateTime.getTime() method

This was selected as the best answer
Avery Henry 2Avery Henry 2

I don't know why bob's answer got a thumbs down.  DateTime.getTime() provides the unix number down to the millisecond.

Alberto Zanatta 5Alberto Zanatta 5
I guess it's because the actual method to use is
DateTime.now().getTime()