Converting a String to Date and Time in PHP


Use strtotime() to convert a string into a Unix timestamp, then format it with date().

Source Code

$dateString = "next Thursday";
$timestamp = strtotime($dateString);
echo date("Y-m-d", $timestamp);
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments