convert unix timestamp php

前端 未结 5 429
你的背包
你的背包 2021-01-13 12:14

I have a database that stores the time for me. I insert it from PHP using

date( \'Y-m-d H:i:s\');

I then use this function to convert it t

相关标签:
5条回答
  • 2021-01-13 12:55

    You can use the strtotime and date function:

    echo date('Ymdhis', strtotime($date));
    
    0 讨论(0)
  • 2021-01-13 12:59

    here you go

    print date("YmdHis",unixtimestamp);
    
    0 讨论(0)
  • 2021-01-13 13:03

    Use date.

    $date = date("YmdHis", $timestamp);
    
    0 讨论(0)
  • 2021-01-13 13:06

    Use the right format :

    date('YmdHis');
    
    0 讨论(0)
  • 2021-01-13 13:09

    If you're using mysql, it has a DATE_FORMAT function. You can call it like

    SELECT DATE_FORMAT(`datefield`, "%Y%m%d%H%i%s") AS `date_formatted` FROM table;
    

    So you get an already formatted date from your database.

    0 讨论(0)
提交回复
热议问题