How to convert to end of that day in php?
This post converting the date to end of that day in php.
1. Code:
<?php function convertMySqlDateToEndDay($mysqlDate){ if (strlen($mysqlDate) <= strlen(("0000-00-00"))) { return $mysqlDate . " 23:59:59"; } $mysqlDate = str_replace("00:00:00", "23:59:59", $mysqlDate); return $mysqlDate; } $str = "2022-06-27"; $str1 = "2022-06-27 00:00:00"; echo(convertMySqlDateToEndDay($str)); echo("<br>"); echo(convertMySqlDateToEndDay($str1)); ?>
2. Example:
Input:
"2022-06-27" "2022-06-27 00:00:00"
Output:
2022-06-27 23:59:59 2022-06-27 23:59:59