JJeyaseelanMCA-7722 avatar image
0 Votes"
JJeyaseelanMCA-7722 asked AgaveJoe commented

C# gives past time

hello there, i have 2 separate projects. when i run the below code from Project1 then it gives me the same time of my laptop time; when i run the same code from another project then it gives 2 hours old time only.

for example, project1 gives time as "13:52" whereas project2 gives time as "11:52". May I know how this different comes and how to resovlve ig?

DateTime now = DateTime.Now().ToString("HH:mm:ss")

thank you

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

The time comes from the system clock. I assume you are running these project on different machines. If the project is run from on the same machine then you have code that is changing the time.

0 Votes 0 ·

thank you for your response AgaveJoe.

both projects are running from same laptop only. but, project2 it shows UTC time rather than my local time..

Even if i disconncted my VPN, project1 always shows my laptop time. but, project2 is always shows UTC time. one more information is project2 is running from docker container.

any suggestions are appreciated

0 Votes 0 ·
AgaveJoe avatar image AgaveJoe JJeyaseelanMCA-7722 ·

Docker container use UTC time by default.

2 Votes 2 ·

0 Answers