0

I need help! Here's script:

<?php
date_default_timezone_set('Europe/Paris');
$time="1303889758";
echo $time."<br>";
$convert=date("G:i:s d. n. Y. ",$time);
//convert $time to our date: output is 9:35:58 27. 4. 2011. 
echo $convert."<br>";
$con2=mktime($convert);
//convert converted time to unix: doesn't work
echo $con2;
?>

I have two script. One script write the time to the document, and the second checks if the time is the same as now. I always get some weird time. And I made this program. And it doesn't work. what's mistake? Thanks!

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by ivan3510
0

Here's how you should be using the Date/Time features in PHP to achieve the same thing:

<?php
$tz = new DateTimeZone('Europe/Paris');
$time = new DateTime("@1303889758",$tz);
$time -> setTimeZone($tz);
$convert = $time -> format("G:i:s d. n. Y. ");
//convert $time to our date: output is 9:35:58 27. 4. 2011. 
echo $convert."<br>";
$con2 = $time -> format("U");
//convert converted time to unix: doesn't work
echo $con2;
?>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.