SetSystemTime

  • Thread starter Thread starter Johann
  • Start date Start date
Daylight savings plus GMT, maybe? Remember that SetSystemTime() sets the
***GMT*** of the unit, so it will be adjusted to find local time based on
where you've told it you are located. To set the time as local time, you
want SetLocalTime().

Paul T.
 
Johann,

I don't know if there's a better solution, but that's mine:

I retrieve date and time from the database server and then set the date/time

// Zeit = time; Datum = date

oClient.Execute("select current time " );
string _cZeit = oClient.Result.Rows[0][0].ToString();
oClient.Execute("select current date " );
string _cDatum = oClient.Result.Rows[0][0].ToString();
SetDateTime( _cDatum, _cZeit );


public static void SetDateTime( string _cDatum, string _cZeit )

System.DateTime oT ;
int _nOffset = DateTime.Now.ToUniversalTime().Hour - DateTime.Now.Hour;;
oT = Convert.ToDateTime( _cDatum );
oT = oT.AddHours( Convert.ToDouble( _cZeit.Substring(0,2)) +
Convert.ToDouble( _nOffset ) );
oT = oT.AddMinutes( Convert.ToDouble( _cZeit.Substring(3,2)) );
oT = oT.AddSeconds( Convert.ToDouble( _cZeit.Substring(6,2)) );
OpenNETCF.Win32.DateTimeEx.SetSystemTime(oT);

Ruediger
 
Back
Top