I've a date like Tue Dec 15 2009. How can I convert it into seconds?
+10
A:
I assume by seconds you mean a UNIX timestamp.
strtotime() should help.
Pekka
2009-12-20 16:15:31
Yeah, UNIX timestamp! that's what i Meant. Thanks for the help
baltusaj
2009-12-20 16:18:42
+3
A:
You mean like an UNIX-timestamp? Try:
echo strtotime('Tue Dec 15 2009');
Hanse
2009-12-20 16:15:50
+5
A:
You can use the strtotime function to convert that date to a timestamp :
$str = 'Tue Dec 15 2009';
$timestamp = strtotime($str);
And, just to be sure, let's convert it back to a date as a string :
var_dump(date('Y-m-d', $timestamp));
Which gives us :
string '2009-12-15' (length=10)
(Which proves strtotime did understand our date ^^ )
Pascal MARTIN
2009-12-20 16:16:30
@Usman : you're welcome :-) ;; well, I've sometimes have had bad surprises with strtotime (especially because I'm french and our dates format is not the same than the english one), so I prefer being careful ^^
Pascal MARTIN
2009-12-20 16:25:34