473,386 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Translating to local time

Some examples in datetime format:
Thu, 25 Jan 2007 10:22:39 -0500
Thu, 25 Jan 2007 09:12:17 -0800
Thu, 25 Jan 2007 10:26:04 -0800
Thu, 25 Jan 2007 10:27:26 -0800
Thu, 25 Jan 2007 19:28:28 +0000

What's the easiest way to get these into my local timezone (AST-Atlantic
Standard Time)?

Change them to GMT, then do -0400?
Jan 25 '07 #1
4 1263
The first thing you need to do is to determine what Time Zone they
originated from.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

The shortest distance between 2 points is a curve.

"Marco Shaw" <marcoDOTshaw_@_gmailDOTcomwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Some examples in datetime format:
Thu, 25 Jan 2007 10:22:39 -0500
Thu, 25 Jan 2007 09:12:17 -0800
Thu, 25 Jan 2007 10:26:04 -0800
Thu, 25 Jan 2007 10:27:26 -0800
Thu, 25 Jan 2007 19:28:28 +0000

What's the easiest way to get these into my local timezone (AST-Atlantic
Standard Time)?

Change them to GMT, then do -0400?

Jan 26 '07 #2
Kevin Spencer <un**********@nothinks.comwrote:
The first thing you need to do is to determine what Time Zone they
originated from.
That's what the -0500, -0800, -0800 etc are for. All relative to UTC.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 27 '07 #3
Marco Shaw <marcoDOTshaw_@_gmailDOTcomwrote:
Some examples in datetime format:
Thu, 25 Jan 2007 10:22:39 -0500
Thu, 25 Jan 2007 09:12:17 -0800
Thu, 25 Jan 2007 10:26:04 -0800
Thu, 25 Jan 2007 10:27:26 -0800
Thu, 25 Jan 2007 19:28:28 +0000

What's the easiest way to get these into my local timezone (AST-Atlantic
Standard Time)?

Change them to GMT, then do -0400?
Try this: (works on my box, but I'm in GMT!)

using System;
using System.Globalization;

class Program
{
static void Main(string[] args)
{
string[] data = new string[]
{"Thu, 25 Jan 2007 10:22:39 -0500",
"Thu, 25 Jan 2007 09:12:17 -0800",
"Thu, 25 Jan 2007 10:26:04 -0800",
"Thu, 25 Jan 2007 10:27:26 -0800",
"Thu, 25 Jan 2007 19:28:28 +0000"};

foreach (string x in data)
{
Parse(x);
}
}

static void Parse (string x)
{
DateTime dt = DateTime.ParseExact
(x, "ddd, dd MMM yyyy HH:mm:ss zzz",
CultureInfo.InvariantCulture,
DateTimeStyles.AdjustToUniversal);

dt = dt.ToLocalTime();
Console.WriteLine (dt);
}
}
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 27 '07 #4
I thought so, but I was unfamiliar with the DateTime format syntax being
used, so I was not going to assume that this was the case. After doing some
research, I have found this format as part of RFC 822 (ARPA Internet Text
Message).

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

The shortest distance between 2 points is a curve.

"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP************************@msnews.microsoft.c om...
Kevin Spencer <un**********@nothinks.comwrote:
>The first thing you need to do is to determine what Time Zone they
originated from.

That's what the -0500, -0800, -0800 etc are for. All relative to UTC.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Jan 29 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ken Fine | last post by:
I'm using XMLHTTP to screen-scrape many thousands of pages of content as part of a data-structuring project. One issue that I'm running into is that some entities such as curly quotes and curly...
12
by: Charles Law | last post by:
Hi guys A bit of curve ball here ... I have a document (Word) that contains a series of instructions in sections and subsections (and sub-subsections). There are 350 pages of them. I need to...
23
by: gregf | last post by:
I have a paragraph of text pasted into a word document, it's in Polish, complete with polish characters. They show up just fine in word, but the program I use for web page programming, HomeSite,...
1
by: davelist | last post by:
I'm guessing there is an easy way to do this but I keep going around in circles in the documentation. I have a time stamp that looks like this (corresponding to UTC time): start_time =...
1
by: yashgt | last post by:
In our ASP .NET 1.1 application, we query the database to obtain a list of categories such as "Agriculture", "Business", etc. and display them to the user, each against a checkbox. The names of...
1
by: timn | last post by:
Translating Access SQL queries into SQL subqueries. -------------------------------------------------------------------------------- I have a query in Access that uses a subquery, I would like...
2
by: Andrus | last post by:
I have resource files in different languages created by VCS 2005 Express. I want to use those files to translate reports at runtime. I have text to be translated as string. I think I need to...
5
by: GHUM | last post by:
hello, in my application I am using hSem = win32event.CreateSemaphore (None, 1, 1,"stringincludinginterfaceandport") rt=win32event.WaitForSingleObject (hSem, 0) if rt !=...
15
by: hofer | last post by:
Hi, Let's take following perl code snippet: %myhash=( one =1 , two =2 , three =3 ); ($v1,$v2,$v3) = @myhash{qw(one two two)}; # <-- line of interest print "$v1\n$v2\n$v2\n"; How...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.