Printing A MongoDB Date From PHP

前端 未结 5 450
忘了有多久
忘了有多久 2020-12-28 17:53

How in PHP do I get the regular timestamp format out of a MongoDB date?

Assume I have:

$my_date;
print_r($my_date);
         


        
5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-28 18:45

    First, create date from millisecond using given function:

    public function showdatefn($mili)
    {   
        $seconds = (string)$mili / 1000;
        return date("d-m-Y", $seconds); 
    }   
    $date =$this->showdatefn();
    

    This will give you correct date.

提交回复
热议问题