- Instant help with your Php coding problems

Convert date to timestamp in PHP

Question:
How to convert date to timestamp in PHP?
Answer:
$date = new DateTime($dateStr);

$timestamp = $date->getTimestamp();
Description:

To convert a date to a Unix timestamp in PHP first create a DateTime object from your date. If you have a DateTime object simply call its getTimestamp method to get the timestamp value.

Share "How to convert date to timestamp in PHP?"
Interesting things
ChatGPT in a nutshell