Hi i am not able to understand What is the difference between printing System.now() and after using String.valueOf(System.now()) bcz both giving me different out/put.
Example:
System.debug(' date()'+System.now()); getting o/p 2013-08-12 06:26:18
System.debug(' date()'+String.valueOf(System.now())); o/p 2013-08-11 23:26:18
Can any one please explain me why i am getting two different date outputs.
Best Answer
This will be as per local time zone of the user
Returns the current date and time in the GMT time zone.
Reference:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_system.htm http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_string.htm
Update:
http://www.salesforce.com/us/developer/docs/soql_sosl/Content/sforce_api_calls_soql_select_convert_time_zone.htm
SOQL queries in a client application return dateTime field values as Coordinated Universal Time (UTC) values. You can use convertTimezone() in a date function to convert dateTime fields to the user's time zone.