Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: userc865b
Added: Jan 25, 2018 11:31 AM
Modified: Jan 29, 2018 10:28 AM
Views: 12
Tags: php
creates DateTime Onject from Unix time
  1. <?
  2. $currentdate=time();
  3. $myDate=\DateTime::createFromFormat("U","1516896685");
  4. $formattedString=$myDate->format("c");
  5. //$curentHourMinutesString=$curretDateObject->format("H:i");
  6.  
  7. // Alterantive better Solution
  8.  
  9.  
  10.  
  11. $date = new DateTime();
  12. $date->setTimestamp(1476913701);
  13. echo $date->format('U = Y-m-d H:i:s') . "\n";