search

Home  >  Q&A  >  body text

How to convert this date format?

Can anyone help me to see how to convert the time format 20182800255 into 2018-02-08 00:02:55?

If the month, day and hour are 1 digit

when 0 is not added
SophieSophie2482 days ago1169

reply all(4)I'll reply

  • 董先生

    董先生2018-02-11 13:31:15

    First take out the time and then process it, example:

    <?php


    ## $a=date("m");

    If ($ A/10 & LT; 1) {// Determine whether the month is zero

    $ b = $ a/10*10;

    Echo " Today is " . $b . "<br>";

    }

    ?>


    reply
    0
  • 董先生

    Do not need if if IF will directly remove the monthly format by 10,

    董先生 · 2018-02-11 16:35:39
    董先生

    Then, take out a specific position to judge the value, and output it after processing.

    董先生 · 2018-02-11 16:47:21
    董先生

    <?php //Please enter your php code $y=date("Y"); $m=date("m")/10*10; $d=date("d"); $t=date("H:i:s"); echo $y."-".$m."-".$d." ".$t."<br>"; ?>

    董先生 · 2018-02-12 09:55:58
  • Cancelreply