-1

How to get db server time using linq in selenium C# without using add and substract. Date.TimeNow is giving system time (EST) but the server is with different time (CST). As per instructions I am not supposed to use Add or substraction. Could someone help me with this.

  • Your question is very confusing. Why are you using Linq to SQL, but not querying a database? What are you trying to add or subtract from? Do you mean DateTime.Now rather than Date.TimeNow? – Necoras Sep 14 '16 at 20:20
  • simple answer: you can't. Long answer: No you cannot. Unless the server is exposing an api or putting it on he webpage you can't access the server directly – Steve Sep 14 '16 at 20:20

1 Answers1

0
 DateTime serverTime = DateTime.Now; // current Time
 DateTime utcTime = serverTime.ToUniversalTime; // convert it to Utc

 TimeZoneInfo timezoneinfo = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
 DateTime localTime = TimeZoneInfo.ConvertTimeFromUtc(utcTime, timezoneinfo ); // convert from utc to local.
GANI
  • 2,013
  • 4
  • 35
  • 69