date('dmY H:i', $timestamp); 

How to deduct for example 3 hours?

    2 answers 2

    if you have $ timestamp in UNIX format, then there is no place to be easier

     $timestamp-3*60*60 
    • @Ale_x, oh :) Something I really ..) Thank you so much! - ModaL
    • @Ale_x, and if the format is not UNIX, but simply a time () function, I need to take 12 hours from the current time. Tried your way did not help. - chuikoff pm

    time

     $time = time() - 3 * 60 * 60; // секунды echo date('dmY H:i', $time); 

    strtotime

     $time = strtotime('-3 hours'); echo date('dmY H:i', $time); 

    Datetime

     $date = new \DateTime('-3 hours'); echo $date->format('dmY H:i');