Wednesday, August 27, 2008

How to convert Unix Timestamp to Mysql Timestamp - Time() to String using php

If you want to convert the Unix timestamp into a string like mysql timestamp you can take a look at following code. Unix timestamp is not human readable so there are situations where you need to convert it into a human readable form.


<?php

$time_now = time();

echo $time_now; //output example: 1219848654
echo '<br />';

$str_time = date('Y-m-d H:i:s', $time_now);

//look at php date function for more options

echo $str_time; // 2008-08-27 14:50:54

?>


Get Free Sinhala IT Learning Videos Kuppiya.com



Get custom programming done at GetAFreelancer.com!

No comments:

Post a Comment