Hi

I'm trying to subtract exactly 24 hours from a timestamp.

2012-09-22 19:15:00

subtracted 24 hours with code below =>

2012-09-21 07:09:00 which is not what I want it to be I need it to be 2012-09-21 19:15:00

What am I doing wrong?

Thanks Nikolaj

Code:

$dato_begivenhed = $row['event_date'];
echo $dato_begivenhed;
echo "<br>";
$date = new DateTime($dato_begivenhed);
$date->modify("-24 hours");
echo $date->format("Y-m-d hⓂs");

    Perhaps you should try to change the last line in your code:

    echo $date->format("Y-m-d hⓂs");

    to

    echo $date->format("Y-m-d H:i:s");

    The "m" in your original time-format refers to the month ... and the small "h" refers to the hour-format where you get the value "7 PM" ... The capital H gives you 19 which is what you want.

      better:

      echo date('Y-m-d H:i:s', strtotime("-1 day", strtotime($row['event_date'])));

        Hi NetRoam - that worked.

        Can you also tell me how I store

        echo $date->format("Y-m-d H:i:s");

        in forexample $deadline - I can't seem to make it work

          $deadline = $date->format("Y-m-d H:i:s");
            Write a Reply...