Get current date time from server and convert it into local time in c#

前端 未结 6 655
一生所求
一生所求 2021-02-04 14:51

Help: I have a server which is having time in GMT-07.00 hours. My local time is GMT+05.30 hours. I need to get current date and time from server and convert this date and time i

6条回答
  •  花落未央
    2021-02-04 15:41

    if you want to add 12 Hours and 30 minutes to your Server time to get equavalent localtime(assuming you have server time), you can use AddHours() and AddMinutes() functions to add the 12:30 hours

    Try This:

    DateTime dt= /*your server time*/;
    dt=dt.AddHours(12);
    dt=dt.AddMinutes(30);
    

提交回复
热议问题