The date() function returns the current server timestamp and you can format it according to a set of parameters. The syntax is date(format,timestamp); If timestamp is not given, current date and time is assumed.
Here are some date() function formats for your reference.
Usually, the format that we used to save date in our table is Y-m-d in which the result is something like this: 2016-01-21. So to make your date more readable to users, you need to format it.
Code
<?php
$date_posted="1970-01-01";//Let's just assume that the value from the table is like that.
echo date("M d, Y",strtotime($date_posted));
?>
Output Date and Time Format
Hope this helps! Good day guys! ^_^
No comments:
Post a Comment