How to show different time zone according to timezone?

amir kian asked on August 1, 2020 09:35

I need to show different times on my site such as London, Canada,u.s.

I wonder whether is a function on that can get time zone cod and send time to me?

I've found this metheod

<%# GetCustomDateTime(DateTime.Now, "GreenwichMeanTime") %>

but how can I figure out which time zone I should set for "GreenwichMeanTime" to get my time zone that I want? I've tried this <%# GetCustomDateTime(DateTime.Now, "CentralAmerica") %>

in a webpart but it dosent show anything!

Recent Answers


Dmitry Bastron answered on August 3, 2020 09:59

Hi Amir,

You can find all time zones in Time Zones application in CMS. There you can find Code Name for the time zones you need.

0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on August 3, 2020 10:19

Ah, I think I've got why you are having troubles with using this code in your web part. These methods are supposed to be used in ASCX Transformations, not in the web parts. But you can try the following method instead:

<%@ Import Namespace="CMS.DocumentEngine.Web.UI" %>
...
<%# TransformationHelper.HelperObject.GetCustomDateTime(DateTime.Now, "CentralAmerica") %>
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.