$dtNow = new \DateTime(); $beginOfDay = clone $dtNow; $beginOfDay->modify('today'); $endOfDay = clone $beginOfDay; $endOfDay->modify('tomorrow'); $endOfDay->modify('1 second ago'); $start_timestamp = $beginOfDay->getTimestamp(); $end_timestamp = $endOfDay->getTimestamp(); echo 'Start: '.$start_timestamp." [".date("Y-m-d H:i:s",$start_timestamp)."]"."\n"; echo 'End: '.$end_timestamp." [".date("Y-m-d H:i:s",$end_timestamp)."]"."\n";
Also, you can get first and last timestamps of a current month:
Continue reading How to get timestamp of start to end (current) day period on PHP?