Home All Groups Group Topic Archive Search About
Author
24 Nov 2004 7:37 AM
Chakra
I have a windows application, where i want to save the date and time of the
transaction in the database, after converting it to the datetime of the
locale of the server. When the same transaction is displayed back to the
client, i want to convert it back to the datetime of the locale of the
client PC, and display it .

How can this be done ?

Author
24 Nov 2004 11:22 AM
Carlos J. Quintero [MVP]
The Date type has ToUniversalTime() and ToLocalTime() methods:

  Dim dtUTC As Date
  Dim dtLocalTime As Date
  Dim dtLocalTimeAgain As Date

  dtLocalTime = System.DateTime.Now()

  dtUTC = dtLocalTime.ToUniversalTime()

  dtLocalTimeAgain = dtUTC.ToLocalTime()

A note: you should get the transaction date on the server side (in Oracle
you execute "SELECT SYSDATE FROM DUAL"), convert it to UTC and return it
back to the client, which in turn converts it into local time. Otherwise, if
you get the transaction date on the client side and pass it to the server,
the client Windows machine could have the clock wrong.

--

Carlos J. Quintero

The MZ-Tools all-in-one add-in, now for .NET: http://www.mztools.com


Show quote
"Chakra" <r_chakravar***@hotmail.com> escribió en el mensaje
news:%23eP9Obf0EHA.1524@TK2MSFTNGP09.phx.gbl...
>I have a windows application, where i want to save the date and time of the
> transaction in the database, after converting it to the datetime of the
> locale of the server. When the same transaction is displayed back to the
> client, i want to convert it back to the datetime of the locale of the
> client PC, and display it .
>
> How can this be done ?
>
>

AddThis Social Bookmark Button