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
Madhusudan Singh 19Madhusudan Singh 19 

Convert String Date Time, to User's timezone format

Hi,

I have a string as 2021-07-22T13:13:01Z, I wanted to convert it to user's timezone. How can I do this.

Regards
Madhusudan Singh
SwethaSwetha (Salesforce Developers) 
HI Madhu,
Recommend reviewing https://salesforce.stackexchange.com/questions/154024/display-string-datetime-in-current-user-locale according to which you can use format() without any parameters.

Also see https://salesforce.stackexchange.com/questions/66352/convert-datetime-of-one-timezone-to-datetime-of-another-timezone?rq=1

Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you
Suraj Tripathi 47Suraj Tripathi 47

Hi,

To change the time zone of the organization
Classic UI

1. Navigate to Setup | Company Profile | Company information | Default Time Zone
2. Select the required time zone.

Lightning Experience UI

1. Click the Gear Icon | Setup | Company Settings | Company Information
2. Change the time zone.
Note: This will be set as the default time Zone for any new Users added to your organization, but the existing Users will continue to have the time zone settings defined for them individually.
 
To change the time zone for the affected users
Note: These steps can be completed by the Users themselves.
Classic UI
1. Go to your name | My Settings | Personal | Language & Time Zone
2. Set the time zone.

Lightning 

1. Click the avatar icon | Settings | My Personal Information | Language & Time Zone
2. Change the time zone.
 
To change the time zone for the affected users
Note: These steps should be performed by the system administrator.
Classic UI
1. Go to Setup | Manage Users | Users
2. Click on the affected User’s name.
3. Click Edit and change the time zone to the required value.

Lightning UI

1. Click on the gear icon | Setup | Users | Users.
2. Click on the affected User’s name.
3. Click Edit and change the time zone to the required value.
 
If the time zone remains the same for everyone, the values within date/time fields will remain constant for all Users on the records.
Thank You