Change Timezone

Hi,

I use Now.ToString(“dd-MM-yyyy HH:mm:ss”) for my date and it’s work in local. But when i run my process on the tenant, i’m not in UTC+2 (French time) but in UTC+0.

For example, in local i have 17:15 but in tenant i have 15:15.

I try many solutions found on the web but that doesn’t work or i don’t understand :frowning:

Who can help me with that ?

Thanks !

Hello,

Try this:

Hello,

I have already try this, but i don’t understand how it’s work :confused:

Hey @Christopher_p

What do you mean by trying in tenant ?

Thanks
#nK

Hey !

I mean, the orchestrator. We have one for dev, one for rec and one for prod.

You may try this:

str_datetime = Datetime.Now.AddHours(2).ToString()

Also, you may check which is the tenant timezone:

More details about tenant settings: Configuring tenant settings at the tenant level

Hi Marian,

If i add 2 hours in my date, in local i will have H+2

The timezone in application settings is on UTC+2. Because in France we have UTC+2 in summer and UTC+1 in winter. So i need to dynamize that :confused:

So @Christopher_p

You are running the process in some other machine and you want to maintain time in France timezone is that correct ?

Yes ! When i go in the machine, time is the same i have on my computer, so i don’t understand why i have H-2 on my process in this machine

hi @Christopher_p ,
What i get here is,
first : your local PC has a different timezone with your tenant machine, u’re UTC+2 and Tenant UTC+0. is it correct?

if it’s correct, secondly : what u want is, u want to have a same result for the time either in local or tenant? i.e Local 17.15 & Tenant 17.15 (which is should + 2 hours).

Is it correct?

Hi Felix,

When I connect to the server, it is at the same time as my local PC, yet my files come up with the time UTC+0 which I don’t understand.

I want have same hour on my files as on my local PC, yes !

Thanks

What’s the code you’re using currently for that time thing please ?

I use : Now.ToString(“dd-MM-yyyy HH:mm:ss”)

Hi Christoper,
Ah i see, so basically your local & machine have a same time which is UTC + 2, but when u produce your file using Now.ToString(“dd-MM-yyyy HH:mm:ss”), it shows UTC + 0, is it?

Yes it’s for what i search for function for keep my UTC+2 or (“French/Paris”). Because we have UTC+1 and UTC+2 in France if we are in summer or winter

Better to keep all the time in the UTC timezone as in the Rest API calls, the date data are presented in the UTC (Coordinated Universal Time) timezone.

As the UTC/GMT never changes, but rather the country adheres to a different time-zone during DST, we are not changing it either in the Orchestrator.

You may try these approaches:

In case you need the local time, use this code:

"Local Time: " + DateTime.ParseExact(Convert.ToString(Now),"MM/dd/yyyy HH:mm:ss",System.Globalization.CultureInfo.InvariantCulture).AddHours(0).ToString

In case you need the UTC time, use this code:

"Time in UTC: " + TimeZoneInfo.ConvertTimeToUtc(DateTime.Parse(Convert.ToString(Now))).ToString

Or you can do this if you need to keep all the time +2 hours in UTC:

"Time in UTC +2: " + TimeZoneInfo.ConvertTimeToUtc(DateTime.Parse(Convert.ToString(Now))).AddHours(2).ToString

Example:

image

3 Likes

Thanks, it’s more understandable for me !

I can just change the Addhours(2) by Addhours(1) when we are in winter time and keep 2 for DST, thanks !

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.