Welcome Guest, Not a member yet? Register   Sign In
php date mktime related question
#1

[eluser]quasiperfect[/eluser]
hi

can anyone spot the bug in this code because i'm going nuts.
thanks a lot

Code:
function to_timestamp($str) {
$segmente = explode(" ",$str);
$data = explode("-",$segmente[0]);
$timp = explode(":",$segmente[1]);
$timestamp = mktime($timp[0], $timp[1], $timp[2], $data[1], $data[2], $data[0]);
return $timestamp;
}
$str="2008-11-07 10:02:00";
$timestamp = to_timestamp($str);
echo 'this script should return '.$str.' insted is returning '.date("Y-m-d H:m:s",$timestamp).'<br />';

for
Code:
$str="2008-10-07 13:02:40"
this script should return 2008-10-07 13:02:40 insted is returning 2008-10-07 13:10:40

after some random testing i observed that the month is passed to the minutes
change the month to any month and see the result at minutes
#2

[eluser]Pascal Kriete[/eluser]
Minute is i, not m Wink .

Also, strtotime will do the job natively.
#3

[eluser]quasiperfect[/eluser]
damn i'm a moron ty inparo




Theme © iAndrew 2016 - Forum software by © MyBB