You need to sign in to do that
Don't have an account?

Problem with system.now()
There is a statement called
so.Last_Stage_Change__c = system.now();
system.debug('Current time:'so.Last_Stage_Change__c);
and the value of so.Last_Stage_Change__c should be today's date and time which is 10/4/2012 hh:mm:ss
but am getting yesterday's date and time. I mean the value which is being assigned to so.Last_Stage_Change__c is 10/3/2012 hh:mm:ss
Can anyone tell me what is the problem here and how does this system.now() work?
System.now() will return time and date as per timezone specified while Org Creation..This could be one of the reason, why there is difference in timings. Please ask your system administrator to look into this.
Ok. And does this time zone changes automatically w.r.t the country from where I login ?
TestClasses run as per system mode i.e. mean as specified in Org, Try finding out TimeZone from
MyPersonal Information --->Personal Information .
and lemme know with your place of login.
if your place of login is india, then Timezone is +5.30 GMT
Time Zone is (GMT+05:30) India Standard Time (Asia/Calcutta).
I need both Timezones
Timezone set in your Org and Timezone as per your login Place
One is India and another is Canada.
Dude,
There is a difference of 09:30 hrs between both the timings,
for eg:
GMT +5:30 - GMT+4:00 = 09:30 hrs. So,need to worry in that case.
Move on
OK. What steps do I need to follow then?
What you want to achieve from this?
SalesForce stores all your data as per Your Org Timezone.
If your working on TestClasses, you don't need to concern at all. As it wont actually commit data to the DB.
Hi,
Will this help you in any way?
datetime myDateTime = datetime.now();
system.debug(myDateTime.format('MM/dd/yyyy HH:mm:ss', 'America/New_York'));
system.debug(myDateTime.format('MM/dd/yyyy HH:mm:ss', 'Europe/Amsterdam'));
system.debug(myDateTime.format('MM/dd/yyyy HH:mm:ss', 'Pacific/Fiji'));
Kind regards,
Maurice