|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
can anyone please help?
can anyone please help? im stuffed...
|
|
#3
|
|||
|
|||
|
whats epoch? if you give me a brief idea, ill try and find out
|
|
#4
|
|||
|
|||
|
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. |
|
#5
|
|||
|
|||
|
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 ??? |
|
#6
|
|||
|
|||
|
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"); |
|
#7
|
|||
|
|||
|
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. |
|
#8
|
||||
|
||||
|
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:
Instead of the way you have it, like this: Quote:
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:
I tested this and it seems to be working fine on 2 different servers. Hope it helps! |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > strtodate() |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|