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
Roshan TamrakarRoshan Tamrakar 

System.Now() and Time Zone

Hi experts,

If I issue the following command in an apex class ...

Code:
    DateTime d = System.now();
    return d;

...the datetime it returns belongs to which time zone?

It returned me "Thu May 01 07:40:07 GMT 2008" when I tested on Thursday 05/01/2008 at 1:25PM. Which is correct according to my timezone location.
(my time zone location is "(GMT+05:45) Kathmandu")

Does it always return GMT time? Or it depends on some settings? If so, what is the place of the setting? How do I access that via code?

Also, is there any method like one in javascript "getTimezoneOffset()"?

According to JavaScript guide:
The getTimezoneOffset() method returns the number of minutes that the current time zone is ahead or behind UTC. For  instance, getTimezoneOffset() returns 300 for U.S. Eastern Daylight Saving Time, which is 5 hours (or 300 minutes) behind UTC.

Thanks,
-Roshan
Ron HessRon Hess
All of the timzone methods are available to you, the Datetime documentation has what you need.

http://www.salesforce.com/us/developer/docs/apexcode/index.htm

then search for datetime

bglkarthikbglkarthik

The url is stale, please provide an updated one.

bglkarthikbglkarthik

Yes, I too have this question?

 

From the a given login, when I check the value in Salesforce Application, I see the datetime in user's timezone, but using the same login when I run a SOQL in Apex Explorer the value is not in GMT.

 

Can anyone throw more light on System.now()

 

(Assuming same login)

In the above eg. What is the time zone that is stored in variable d  ?

If this variable value is inserted into a custom field of type DateTime what what is the value stored in the object?

 

Thanks for your help.