PC Review


Reply
Thread Tools Rate Thread

datetime conversions - US CST

 
 
Mark
Guest
Posts: n/a
 
      25th Aug 2004
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
 
Reply With Quote
 
 
 
 
Jay B. Harlow [MVP - Outlook]
Guest
Posts: n/a
 
      25th Aug 2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
Mark
Guest
Posts: n/a
 
      25th Aug 2004
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]" <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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

 
Reply With Quote
 
Jay B. Harlow [MVP - Outlook]
Guest
Posts: n/a
 
      26th Aug 2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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]" <(E-Mail Removed)> wrote in message

news:<(E-Mail Removed)>...
> > 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" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > 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



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
xml, DateTime conversions and DateTime fields Andy B Microsoft ASP .NET 2 25th Sep 2008 02:43 PM
Millisecond values missing when inserting datetime into datetime column of sql Server Manikandan Microsoft C# .NET 4 18th Jul 2007 08:59 PM
How can I save a DateTime from my C# program into a SQL Server (datetime) database column. Steve Kershaw Microsoft ASP .NET 5 29th Aug 2006 03:10 AM
DateTime time zone conversions not required ! GiriT Microsoft C# .NET 4 22nd Oct 2003 10:31 AM
XML dateTime conversion to DateTime.MinValue accross timezones Symon R Microsoft Dot NET 0 6th Aug 2003 07:50 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:55 AM.