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
Danny IncompanyDanny Incompany 

Server TimeStamp

Hi community,

 

I have created an e-commerce app in which visitors leave information on a form, when they fill the information on the form this creates an object in force.com database. The object foes under the name of the "Site guest user" due that I have the app in a site.

 

After they leave a message on the form, the controller sets the date in the description field:

 

n_cot.DescripcionCotizacion__c ='Compra de prueba dev @: ' + Datetime.now() + txt;

 

If I look at the object, the created date is ok, but the date in the description field (generated by the snippet code above), it is wrong, it is about 6 hours ahead.

 

I have changed the date and time in:

 

-Site Guest User Profile and user

-Admin user

-Company profile

 

Still no change. I am missing something? or this is something related due that I am still in Sandbox? any help appreciated. Thanks!

 

 

jungleeejungleee

Hi

 

I think the time dipsplayed in the Description field is in the GMT timezone, if you want the time captured in the User's time zone then you must use the format instance method.Something like this:

 

Datetime myDT = Datetime.now();
String myDate = myDT.format();

the date in he myDate variable will be in User's timezone.

Hope this helps!!

 

Regards

Sam