Tell me there is a way to translate the value for example 2018-01-01 to the type of record time () ( http://php.net/manual/ru/function.time.php )?

  • one
    strtotime ('2018-01-01'); - AtCliff_
  • Thanks, everything works - Dmitriy

1 answer 1

Is there a way to translate the value for example 2018-01-01 to the type of time () record?

  • Option 1: echo (new DateTime('2018-01-01'))->getTimestamp();

  • Option 2: echo strtotime('2018-01-01');

The first option is preferable ( quote from of.documentation ):

strtotime() not recommended for mathematical operations. It is advisable to use DateTime :: add () and DateTime :: sub () since PHP 5.3, or DateTime :: modify () in PHP 5.2.

  • Thank you, the question has already been decided - Dmitry