I wanted to remove the time from a date/time string. The time is always “T00:00:00” so I use “rtrim” to strip that section from the string.
However, if the last digit in the Date is a “0”, it removes that zero too.
Is this a bug?
For an example please go to php playground php-play.dev and enter the following code…
<?php
$date = "2024-07-10T00:00:00";
$date_minus_time = rtrim($date, "T00:00:00");
print $date; //"2024-07-10T00:00:00"
print "<br>";
print $date_minus_time; //expected "2024-07-10" but got "2024-07-1"