简体   繁体   中英

CodeIgniter - How to Convert timestamp into ISO_8601

I want to ask about how to convert timestamp from my database to ISO_8601 format in Codeigniter

Here is my controller :

public function index()
    {
        $data['viewme'] = $this->home_model->list_data();
        $this->load->view('home', $data);
    }

And this is my model :

function list_data(){
    $sql   = "SELECT * FROM post";
    $query = $this->db->query();
    $data  = $query->result_array();
}

And this is my view:

<?php foreach($viewme as $data): ?>
  <div class=" " title="<?php echo $data['time']?>"><?php echo $data['time']?></div>
<?php endforeach; ?>

The Problem: Time is still in timestamp format...

I have read codeigniter guide and found this

$format = 'DATE_ISO8601';
$waktu = time();

echo standard_date($format, $waktu);

But i dont know where I do to put that code into my codeigniter? any answer?

Many Thanks..

Core PHP code

$timestamp= '7861109272';
$iso8601 = date('c', $timestamp);

Manual

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM