General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 2nd, 2002, 02:26 AM
stuie stuie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Brisbane, Australia
Posts: 39 stuie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 52 sec
Reputation Power: 17
strtodate()

Can I convert a date like "Fri May 17 23:45:47 2002" to epoch?

When I try I get the same result, 1028210400, with all the following dates?

"Thu May 23 07:04:08 2002"
"Tue May 21 10:05:13 2002"
"Sat May 10 04:09:08 2002"

Anyone help?

Thanks fellas

Reply With Quote
  #2  
Old August 5th, 2002, 02:19 AM
stuie stuie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Brisbane, Australia
Posts: 39 stuie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 52 sec
Reputation Power: 17
can anyone please help?

can anyone please help? im stuffed...

Reply With Quote
  #3  
Old August 5th, 2002, 03:57 AM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
whats epoch? if you give me a brief idea, ill try and find out

Reply With Quote
  #4  
Old August 5th, 2002, 11:09 AM
Crowe Crowe is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Huntsille, AL
Posts: 14 Crowe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Crowe Send a message via AIM to Crowe
If your talking about php, I think the function your looking for is

strtotime($string);

It will attempt to put it into a unix time stamp.


Just FYI, since it was asked, Epoch time, by general definition is the point from which time starts. A unix timestamp is the number of seconds since unix epoch, which is 00:00:00 GMT, January 1, 1970. In programming, when people say epoch time, they mean a unix timestamp.

Reply With Quote
  #5  
Old August 5th, 2002, 07:43 PM
stuie stuie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Brisbane, Australia
Posts: 39 stuie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 52 sec
Reputation Power: 17
oops

i forgot to mention in my original that im using strtodate()

Like strdate("Thu May 23 07:04:08 2002");

But no matter what i supply the function i get the same value,

1028210400

I don't get it ???

Reply With Quote
  #6  
Old August 5th, 2002, 09:20 PM
Crowe Crowe is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Huntsille, AL
Posts: 14 Crowe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Crowe Send a message via AIM to Crowe
You also failed to mention what language. Is it php? C? C# C++?

If it's php, there is no strdate function, it's strtotime($string), for which your example would be

strtotime("Thu May 23 07:04:08 2002");

or more exactly

$date_formatted = $strtotime("Thu May 23 07:04:08 2002");

Reply With Quote
  #7  
Old August 5th, 2002, 10:39 PM
stuie stuie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Brisbane, Australia
Posts: 39 stuie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 52 sec
Reputation Power: 17
its php

sorry im doing it in PHP and im using strtotime()

sorry, ive been saying strtodate the whole time. haha but yeah the problem is still the same.

Reply With Quote
  #8  
Old August 5th, 2002, 11:12 PM
Crowe Crowe is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Huntsille, AL
Posts: 14 Crowe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Crowe Send a message via AIM to Crowe
Excellent. I think I can help you now. First off, can you change your date format at all? strtotime doesn't like the format of your string. When you include that much info, it want is like this:

Quote:
Thu May 23 2002 07:04:08


Instead of the way you have it, like this:

Quote:
Thu May 23 07:04:08 2002


Not that the only difference is that the year and seconds is switched.

If you could swith that, you'd be in business. In case you can't, here is my work around:

PHP Code:
// Original String
$date_string "Thu May 23 07:04:08 2002";
// Break it up into parts
list($wkday$month$day$minutes$year) = explode(" "$date_string);
// Put the parts in the order we need
$date_formatted "$wkday $month $day $year $minutes";
// Now use the very picky strtotime 
$final_date strtotime($date_formatted);
// and your ready to go
echo "The Final Date in Unix Format is : $final_date"


I tested this and it seems to be working fine on 2 different servers. Hope it helps!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > strtodate()


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap