This question has already been answered:

How to get a string containing the date in this format:

2016-03-20 

Reported as a duplicate by members of VenZell , zRrr , tutankhamun , Pavel Parshin , user194374 26 Mar '16 at 19:58 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • one
    What's wrong with the standard method <?= date("Ymd");?> ? - user200141
  • Will he return a string in this format? =) - Nikita Rassamahin
  • If yes, then everyone is good - Nikita Rassamahin
  • one
    That's exactly what he will do =) - user200141
  • Thank you. Works great =) - Nikita Rassamahin

2 answers 2

 <?= date("Ymd");?> 

YYYY-mm-dd string

    In your question, the date is not current, just in case I will give an example of how to convert to another format:

     $date = date('d F Y', strtotime('2016-03-20')); var_dump(is_string($date)); // bool(true) echo $date; // 20 March 2016