-1

I was thinking to code it without any help of pre-existing class, but it seems it is complicated. Later I realized that the question is to just substract 1 second from given day.

Some examples: Local time, Australia/Melbourne

2018-07-26T00:00:00 to 2018-07-25T23:59:59

2018-08-01T00:00:00 to 2018-07-31T23:59:59
kenpeter
  • 6,266
  • 11
  • 57
  • 86
  • See: https://stackoverflow.com/questions/3905193/convert-time-and-date-from-one-time-zone-to-another-in-php – Ole Haugset Jul 25 '18 at 13:28
  • Possible duplicate of [Convert time and date from one time zone to another in PHP](https://stackoverflow.com/questions/3905193/convert-time-and-date-from-one-time-zone-to-another-in-php) – Ole Haugset Jul 25 '18 at 13:29
  • @OleHaugset I see nothing about changing timezones in this question, only substracting one second. What is it that you are trying to do kenpeter. Substract one second? – Félix Adriyel Gagnon-Grenier Jul 25 '18 at 14:04

2 Answers2

0

Try this, you are just trying subtract one second from the date,

$date = new DateTime('2018-08-01T00:00:00');
$date->sub(new DateInterval('PT1S'));
echo $date->format('Y-m-d-H-i-s');
Sugumar Venkatesan
  • 3,782
  • 7
  • 39
  • 71
0

I'm not sure I understand your question correctly, but if you want to just go to the previous day and remove one minute then you can do this :

$time = "2018-07-26T00:00:00";
$unixtimeMinusOneSecond = strtotime($time)-1;

echo date("Y-m-d H:i:s", $unixtimeMinusOneminute);
Zony86
  • 104
  • 7