Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to update the Date Time field when its on the Different Time zone in c#

(0) ShareShare
ReportReport
Posted on by

Hello Guys,

I am facing a issue that the date time field in the form is being saved wrongly in the database and the server is configured at CST time zone.

So how can i manage it on the code level so that i will be able to save the actual date which i am passing from the UI. And i don't want to change in the CRM like behavior of the field.

Server is at CST Time Zone and i am passing Date from IST.

A great help will be much appreciated.

Thanks

Shashikant Saxena

  

*This post is locked for comments

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: How to update the Date Time field when its on the Different Time zone in c#

    Hi,

    The datetime field are always stored in UTC time zone in database. These are than converted into users local/configured time zone. So if IST users enters a date, it will be saved as UTC in database. For a CST user, the UTC date time will then be converted from UTC to CST.  If you want to save the date time as is then you need to change the behaviour of the date to Timezone Independent.

    So even if you manipulate the date using code & timezone. It will still be saved based on the selecte behaviour of the field.

    You can read more about this here: www.magnetismsolutions.com/.../introduction-to-behaviours-of-date-and-time-fields-in-dynamics-365

    Hope this helps.

  • Community Member Profile Picture
    on at
    RE: How to update the Date Time field when its on the Different Time zone in c#

    Thanks for the response,

    I have already tried this approach but it does not work for me.

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: How to update the Date Time field when its on the Different Time zone in c#

    Hi,

    You can use TimeZoneInfo class

    TimeZoneInfo targetZone = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");

    DateTime newDT = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, targetZone);

    Check links below hope it helps.

    stackoverflow.com/.../creating-a-datetime-in-a-specific-time-zone-in-c-sharp

    www.codeproject.com/.../How-can-i-get-CST-Central-Standard-Time-in-asp-net

    Thanks,

    Ridhima

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans