Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Convert date recevied as String to date in local time zone

Reply
Thread Tools

Convert date recevied as String to date in local time zone

 
 
deepak_kamath_n@yahoo.co.in
Guest
Posts: n/a
 
      04-28-2007
Hello,

I have the following scenario:
1. My application receives the date from another application as a
string
2. The other application is running in a different time zone as
compared to my app.
3. I need to convert the received date string in to a date w.r.t my
local time zone.

For e.g., the string I recv is : "Mon Oct 16 16:20:06 EDT 2006"
How do I convert this to a date w.r.t my local timezone?

Any help on this is much appreciated!

Regards,
Deepu

 
Reply With Quote
 
 
 
 
Dennis Jones
Guest
Posts: n/a
 
      04-28-2007

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ps.com...
> Hello,
>
> I have the following scenario:
> 1. My application receives the date from another application as a
> string
> 2. The other application is running in a different time zone as
> compared to my app.
> 3. I need to convert the received date string in to a date w.r.t my
> local time zone.
>
> For e.g., the string I recv is : "Mon Oct 16 16:20:06 EDT 2006"
> How do I convert this to a date w.r.t my local timezone?


First convert the received time to UTC, then convert from UTC to your local
time zone.

- Dennis


 
Reply With Quote
 
 
 
 
deepak_kamath_n@yahoo.co.in
Guest
Posts: n/a
 
      04-29-2007
Which function can I use to convert the date "Mon Oct 16 16:20:06 EDT
2006" to UTC? The problem is I could not find a fucntion that takes
time timezone(in this case "EDT") as an input parameter and gives me
the corresponding UTC.

On Apr 28, 10:02 am, "Dennis Jones" <(E-Mail Removed)> wrote:
> <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed) ps.com...
>
> > Hello,

>
> > I have the following scenario:
> > 1. My application receives the date from another application as a
> > string
> > 2. The other application is running in a different time zone as
> > compared to my app.
> > 3. I need to convert the received date string in to a date w.r.t my
> > local time zone.

>
> > For e.g., the string I recv is : "Mon Oct 16 16:20:06 EDT 2006"
> > How do I convert this to a date w.r.t my local timezone?

>
> First convert the received time to UTC, then convert from UTC to your local
> time zone.
>
> - Dennis



 
Reply With Quote
 
osmium
Guest
Posts: n/a
 
      04-29-2007
<(E-Mail Removed)> wrote:

> Which function can I use to convert the date "Mon Oct 16 16:20:06 EDT
> 2006" to UTC? The problem is I could not find a fucntion that takes
> time timezone(in this case "EDT") as an input parameter and gives me
> the corresponding UTE.


In the time you have wasted looking for some code, you could have written
the code yourself! Start coding.


 
Reply With Quote
 
=?ISO-8859-1?Q?Erik_Wikstr=F6m?=
Guest
Posts: n/a
 
      04-29-2007
On 2007-04-29 15:16, osmium wrote:
> <(E-Mail Removed)> wrote:
>
>> Which function can I use to convert the date "Mon Oct 16 16:20:06 EDT
>> 2006" to UTC? The problem is I could not find a fucntion that takes
>> time timezone(in this case "EDT") as an input parameter and gives me
>> the corresponding UTE.

>
> In the time you have wasted looking for some code, you could have written
> the code yourself! Start coding.


Well, almost true but timezons complicates a lot of things when DST is
considered (especially over in the US where every county seems to have
it their own way).

--
Erik Wikström
 
Reply With Quote
 
osmium
Guest
Posts: n/a
 
      04-29-2007
"Erik Wikström" wrote:

> On 2007-04-29 15:16, osmium wrote:
>> <(E-Mail Removed)> wrote:
>>
>>> Which function can I use to convert the date "Mon Oct 16 16:20:06 EDT
>>> 2006" to UTC? The problem is I could not find a fucntion that takes
>>> time timezone(in this case "EDT") as an input parameter and gives me
>>> the corresponding UTE.

>>
>> In the time you have wasted looking for some code, you could have written
>> the code yourself! Start coding.

>
> Well, almost true but timezons complicates a lot of things when DST is
> considered (especially over in the US where every county seems to have it
> their own way).


The example he posted showed EDT which has a nice fixed relationship to UTC.
So someone has already solved the problem you allude to.


 
Reply With Quote
 
deepak_kamath_n@yahoo.co.in
Guest
Posts: n/a
 
      04-30-2007
My requirement is *not* just to convert a date string in "EDT" time
zone to UTC ( if it were this post would not exist at all).

I may get the date string from any time zone and I need to convert
this to UTC. Now to do this, I need to know the offset of the time
zone in question from UTC, the abbreviation such as EDT would not
suffice.

Is there any API that provides me with the offset for a given
abbreviated timezone or is creating a database of such offsets and
using it the only option?

--Deepu


On Apr 29, 9:00 pm, "osmium" <(E-Mail Removed)> wrote:
> "Erik Wikström" wrote:
> > On 2007-04-29 15:16, osmium wrote:
> >> <(E-Mail Removed)> wrote:

>
> >>> Which function can I use to convert the date "Mon Oct 16 16:20:06 EDT
> >>> 2006" to UTC? The problem is I could not find a fucntion that takes
> >>> time timezone(in this case "EDT") as an input parameter and gives me
> >>> the corresponding UTE.

>
> >> In the time you have wasted looking for some code, you could have written
> >> the code yourself! Start coding.

>
> > Well, almost true but timezons complicates a lot of things when DST is
> > considered (especially over in the US where every county seems to have it
> > their own way).

>
> The example he posted showed EDT which has a nice fixed relationship to UTC.
> So someone has already solved the problem you allude to.



 
Reply With Quote
 
=?ISO-8859-1?Q?Erik_Wikstr=F6m?=
Guest
Posts: n/a
 
      04-30-2007
On 2007-04-30 04:43, http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> My requirement is *not* just to convert a date string in "EDT" time
> zone to UTC ( if it were this post would not exist at all).
>
> I may get the date string from any time zone and I need to convert
> this to UTC. Now to do this, I need to know the offset of the time
> zone in question from UTC, the abbreviation such as EDT would not
> suffice.
>
> Is there any API that provides me with the offset for a given
> abbreviated timezone or is creating a database of such offsets and
> using it the only option?


As I said, DST makes a mess of this since the offset depends partially
on what date it is, however I suspect that all platforms except some
embedded ones will have some way of converting between different times,
ask in a group for your platform and you'll probably get an answer.

--
Erik Wikström
 
Reply With Quote
 
Boris
Guest
Posts: n/a
 
      05-01-2007
On Sat, 28 Apr 2007 06:12:25 +0200, <(E-Mail Removed)> wrote:

> Hello,
>
> I have the following scenario:
> 1. My application receives the date from another application as a
> string
> 2. The other application is running in a different time zone as
> compared to my app.
> 3. I need to convert the received date string in to a date w.r.t my
> local time zone.
>
> For e.g., the string I recv is : "Mon Oct 16 16:20:06 EDT 2006"
> How do I convert this to a date w.r.t my local timezone?


You might want to have a look at
http://www.boost.org/doc/html/date_time.html.

Boris
 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Convert UTC DateTime to Local Time (Not My Local Time) Jonathan Wood ASP .Net 1 11-01-2009 12:08 AM
convert time string in UTC to time in local time davelist@mac.com Python 1 03-11-2007 12:57 AM
How to gather IP address from Recevied: headers David Mahon Perl Misc 1 12-03-2005 02:45 PM
how can I convert date infomation to a string just includes the date not the time wgan Java 7 07-08-2004 07:08 PM
Multi-time zone date/time value? davout Java 3 10-16-2003 07:45 PM



Advertisments