By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,041 Members | 1,018 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,041 IT Pros & Developers. It's quick & easy.

datetime conversions - US CST

P: n/a
Hey everybody.

Is there an easy way in vb.net to convert the local time of a machine
to US CST ? My machines are distributed throughout and the server is
requesting we send the time of the txns in US CST.

TIA,
Mark
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Mark,
Unfortunately System.DateTime (VB's Date) only knows how to convert a
Universal Time to Local Time & convert Local Time to UniversalTime.

I would recommend that each of your machines convert local time to universal
time, then send that time to the server. The server can then convert the
universal time to local time which will be CST.

You can use
- DateTime.Now - to get current local date & time
- DateTime.UtcNow - to get current date & time in universal time (UTC)
- DateTime.ToUniversalTime - to convert local time to universal time
- DateTime.ToLocalTime - to convert universal time to local time
Hope this helps
Jay

"Mark" <ma*****@yahoo.com> wrote in message
news:f4**************************@posting.google.c om...
Hey everybody.

Is there an easy way in vb.net to convert the local time of a machine
to US CST ? My machines are distributed throughout and the server is
requesting we send the time of the txns in US CST.

TIA,
Mark

Nov 21 '05 #2

P: n/a
Thanks Jay.

Unfortunately, in this environment, the server that I referred to is
not the end location and is not in CST. For this particular txn, its
just passing thru the message on to the final dest. So the server
would have the same problem. I haven't looked yet, but does the
localtime include the timezone locally also, so I would have that
information ?

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message news:<uG**************@TK2MSFTNGP12.phx.gbl>...
Mark,
Unfortunately System.DateTime (VB's Date) only knows how to convert a
Universal Time to Local Time & convert Local Time to UniversalTime.

I would recommend that each of your machines convert local time to universal
time, then send that time to the server. The server can then convert the
universal time to local time which will be CST.

You can use
- DateTime.Now - to get current local date & time
- DateTime.UtcNow - to get current date & time in universal time (UTC)
- DateTime.ToUniversalTime - to convert local time to universal time
- DateTime.ToLocalTime - to convert universal time to local time
Hope this helps
Jay

"Mark" <ma*****@yahoo.com> wrote in message
news:f4**************************@posting.google.c om...
Hey everybody.

Is there an easy way in vb.net to convert the local time of a machine
to US CST ? My machines are distributed throughout and the server is
requesting we send the time of the txns in US CST.

TIA,
Mark

Nov 21 '05 #3

P: n/a
Mark,
In case you missed my point. I am suggesting you only send time in universal
time between servers. I would convert local time to universal time on the
originating systems only (not pass thru systems).

No matter what server you are on, or how many you pass thru, the time will
still be universal time. Hence there is no worry as to what the local time
is!
To answer your question, DateTime does not itself keep track as to whether
it is in Local or Universal time you need to do this yourself. I normally do
this via the context of the variable.

You can use System.TimeZone.CurrentTimeZone to find out what the current
time zone on your system is.

Hope this helps
Jay
"Mark" <ma*****@yahoo.com> wrote in message
news:f4**************************@posting.google.c om...
Thanks Jay.

Unfortunately, in this environment, the server that I referred to is
not the end location and is not in CST. For this particular txn, its
just passing thru the message on to the final dest. So the server
would have the same problem. I haven't looked yet, but does the
localtime include the timezone locally also, so I would have that
information ?

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message

news:<uG**************@TK2MSFTNGP12.phx.gbl>...
Mark,
Unfortunately System.DateTime (VB's Date) only knows how to convert a
Universal Time to Local Time & convert Local Time to UniversalTime.

I would recommend that each of your machines convert local time to universal time, then send that time to the server. The server can then convert the
universal time to local time which will be CST.

You can use
- DateTime.Now - to get current local date & time
- DateTime.UtcNow - to get current date & time in universal time (UTC)
- DateTime.ToUniversalTime - to convert local time to universal time
- DateTime.ToLocalTime - to convert universal time to local time
Hope this helps
Jay

"Mark" <ma*****@yahoo.com> wrote in message
news:f4**************************@posting.google.c om...
Hey everybody.

Is there an easy way in vb.net to convert the local time of a machine
to US CST ? My machines are distributed throughout and the server is
requesting we send the time of the txns in US CST.

TIA,
Mark

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.