Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 29th Aug 2011, 10:47 PM   #1
Active Warrior
 
Join Date: 2011
Posts: 52
Thanks: 0
Thanked 2 Times in 2 Posts
Default
How to compare date/times in different timezones?
Share on: 
fb share twitter share gplus share more share

I have 2 date/time strings that I need to compare to see if they are the same date / not. One is "Fri, 26 Aug 2011 14:34:55 GMT" and the other is "Sat, 27 Aug 2011 07:03:02 +1000".

I guess it's a 2-step process:
1) Convert them both to the same timezone, and then
2) Compare the date component of the date/time to see if they're the same date.

I've been searching around and am now totally bewildered and baffled by the various date & time modules available. I have tried a few and can't work out how to do this. I'm not a perl programmer, I'm an occasional dab
tocktik is offline  
Unread 30th Aug 2011, 01:00 AM   #2
HyperActive Warrior
War Room Member
 
lovenot's Avatar
 
Join Date: 2011
Posts: 129
Thanks: 2
Thanked 13 Times in 12 Posts
Default
Re: How to compare date/times in different timezones?
Share on: 
fb share twitter share gplus share more share

Originally Posted by tocktik View Post

I have 2 date/time strings that I need to compare to see if they are the same date / not. One is "Fri, 26 Aug 2011 14:34:55 GMT" and the other is "Sat, 27 Aug 2011 07:03:02 +1000".

I guess it's a 2-step process:
1) Convert them both to the same timezone, and then
2) Compare the date component of the date/time to see if they're the same date.

I've been searching around and am now totally bewildered and baffled by the various date & time modules available. I have tried a few and can't work out how to do this. I'm not a perl programmer, I'm an occasional dab
You are on the right track. Use the date & time modules available to compare them. Look through their documentation. There should be functions for you to use. Convert them into the same format first.

lovenot is offline  
Unread 30th Aug 2011, 02:25 AM   #3
Active Warrior
 
Join Date: 2011
Location: New Delhi
Posts: 73
Thanks: 3
Thanked 6 Times in 4 Posts
Default
Re: How to compare date/times in different timezones?
Share on: 
fb share twitter share gplus share more share

Originally Posted by tocktik View Post

I have 2 date/time strings that I need to compare to see if they are the same date / not. One is "Fri, 26 Aug 2011 14:34:55 GMT" and the other is "Sat, 27 Aug 2011 07:03:02 +1000".

I guess it's a 2-step process:
1) Convert them both to the same timezone, and then
2) Compare the date component of the date/time to see if they're the same date.

I've been searching around and am now totally bewildered and baffled by the various date & time modules available. I have tried a few and can't work out how to do this. I'm not a perl programmer, I'm an occasional dab
You should use date functions and convert it into same timezone. Even you can try converting it into timestamp and then calculate it.

showmack is offline  
Unread 30th Aug 2011, 04:38 PM   #4
HyperActive Warrior
War Room Member
 
Tashi Mortier's Avatar
 
Join Date: 2010
Location: Hesse, Germany
Posts: 349
Thanks: 33
Thanked 82 Times in 64 Posts
Default
Re: How to compare date/times in different timezones?
Share on: 
fb share twitter share gplus share more share

Welcome to the whole world of pain that is connected to working with time and dates in any programming language

I really recommend that you convert the dates into a timestamp, then you can easily work with addition, subtraction and simple comparisons.

You can then always format the timestamps into human-readable format when it's time to show them to a user.

Want to read my personal blog? Tashi Mortier
Tashi Mortier is offline  
Closed Thread


Bookmarks

Tags
compare, date or times, timezones


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 Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 11:32 AM.