sábado, 31 de marzo de 2018

PHP DATE practice 2

<?php

$date = new DateTime('2018/03/29 03:00');   //create  date



echo $date->format('Y-m-d H:i:sP') . "<br><br>";

$date->add(new DateInterval('P30D'));  //add 30 days to the current date


echo $date->format('Y-M-d H:i:sP') . "\n";  print date on  numeric format

echo  "<br><br>";

echo date('l jS \of F Y h:i:s A',time());  // print current date on literal

$date= $date->getTimestamp();  //  convert   a date object to time stamp

echo  "<br><br>";

echo date('l jS \of F Y h:i:s A',$date);   // print the  timestamp of the date object in  literal format


2018-03-29 03:00:00-04:00

2018-Apr-28 03:00:00-04:00

Saturday 31st of March 2018 03:11:52 PM

Saturday 28th of April 2018 03:00:00 AM

http://php.net/manual/en/function.date.php

http://php.net/manual/en/datetime.createfromformat.php

http://php.net/manual/en/datetime.formats.date.php

No hay comentarios:

Publicar un comentario