Updated on Kisan Patel
This post will explain you how to work with date and time in PHP. So here we have list out few PHP date and time functions.
PHP parse_date
function takes a date string (date format accepted by strtotime().) and returns to you an associative array with details of the date.
print_r( date_parse("1990-05-26 18:24") );
PHP time
function return the current unix timestamps. It return the number of seconds that have passed since January 1, 1970.
echo time(); // print the 1422461315
Obviously, Unix timestamps are not very user-friendly. For practical date formats, we need to use PHP strftime
function.
You need to pass the string that tell strftime to how to format date and also pass a timestamp as the second parameter otherwise it will use the current time as the default.
echo strftime(" %a, %B %d, %Y"); // Wed, January 28, 2015