strtotime() is a function that converts a date which is in string format into unix timestamp. Please select the data-type as timestamp instead date or datetime when define table structure.
At the time of saving, we have to just pass the date value which is in string format as argument of strtotime() function and get the timestamp as output of this function. Now, we can save this timestamp in the table.
At the time of using this value, after fetching pass this timestamp value in the date() function as second parameter. Format will be as below:
<?php
//Before saving the value in table,
$timestamp_field_value=strtotime('2010-12-23 12:55:32');
//After fetching the value from table,
echo date('Y-m-d',$timestamp_field_value);
?>
No comments:
Post a Comment
Thanks for your valuable comments.