how to convert timestamp to date in codeigniter

后端 未结 5 1085
暗喜
暗喜 2021-01-21 19:03

I want to convert 1373892900000 to Monday 2013/07/15 8:55 AM in Codeigniter.

However, I keep receiving a totally different result by converting

5条回答
  •  无人及你
    2021-01-21 19:55

    This how to covert timestamp to date very simple:

    echo date('m/d/Y', 1299446702);
    

    to convert timestamp to human readable format try this:

    function unix_timestamp_to_human ($timestamp = "", $format = 'D d M Y - H:i:s')
    {
       if (empty($timestamp) || ! is_numeric($timestamp)) $timestamp = time();
       return ($timestamp) ? date($format, $timestamp) : date($format, $timestamp);
    }
    
    $unix_time = "1251208071";
    
    echo unix_timestamp_to_human($unix_time); //Return: Tue 25 Aug 2009 - 14:47:51
    

    if you want to convert it to a format like this: 2008-07-17T09:24:17Z than use this method

    
    

    for details about date: http://php.net/manual/en/function.date.php

提交回复
热议问题