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
Eager-2-LearnEager-2-Learn 

SF Server Time

Hi,

 

I have a  strange thing going on.  When I am on CS13 (Sandbox) and I perform  a System.debug(System.Now()); it returns a time of 20:42 (8:42pm) and the actual time here is 4:42pm!  If my ORG is setup to be on the New York East Coast then why wouldn't the Sytem.Now() command return the correct time?

 

I am using this javascript with a hard coded expected date/time and it is throwing my results off and the above is why I think it is.

SuperfellSuperfell

System.now() returns a date/time in GMT, not your local timezone.

Jaffer Ali.Jaffer Ali.
Eager-2-LearnEager-2-Learn

Thanks for your support.

 

How can I get this java script line to pull the Eastern New Time.

 

    present = new Date();
    present = present.getTime() + (60000) + (12 * 60 * 60 * 1000);

 

It looks like when I am all done with the comparison of the 'present' value and the finish date I am 12 hours difference.  My fix is to adjust by 12 hours and I made comment in the code so everyone else knows but I would prefer to make it work properly.

 

The entire code is here--NOTE: I did not write this and cannot take credit.

var present;   
var future;    
var tseconds;  
var seconds;   
var minutes;
var hours;
var days;
ID=setTimeout("countdown();", 1000);

function countdown() {
    present = new Date();
    present = present.getTime() + (60000) + (12 * 60 * 60 * 1000);
    // If your time is scheduled for AM set it to PM 
    // If your time is scheduled for PM set it to AM
    // For example, if your timer is set for September 10, 2012 9:00:00 AM
    // then set the future field below to September 10, 2012 9:00:00 PM
    future = new Date("September 10, 2012 9:00:00 PM");
    
    tseconds = (future - present) / 1000;
    if ( tseconds < 0 ) { return; }
    days = tseconds /24/60/60;
    days = Math.floor(days);
    tseconds = tseconds - (days * 24 * 60 * 60);
    
    hours = tseconds /60/60;
    hours = Math.floor(hours);
    tseconds = tseconds - (hours * 60 * 60);
    
    minutes = tseconds /60;
    minutes = Math.floor(minutes);
    tseconds = tseconds - (minutes * 60);
    
    seconds = tseconds;
    seconds = Math.floor(seconds);
    document.getElementById('days').innerHTML = days;  
    document.getElementById('hours').innerHTML = hours;
    document.getElementById('minutes').innerHTML = minutes;
    document.getElementById('seconds').innerHTML = seconds;
    ID=setTimeout("countdown();", 1000);
}