PHP codes for date and time

creating php Timestamp


Date, month and year format to Timestamp

$time_stamp = strtotime("$year/$month/$day");


$time_stamp = strtotime("$year/$month/$day $hour:$minute:$second");

Time stamp to date,month and year format

$p= date("d/m/y",$timestamp);


$p= date("d/m/y h:i:s",$timestamp);//i for minute

Date function

$d = date(d);
$m = date(m);
$y = date(y);
$h = date(H);
$i = date(i);//Minute
$s = date(s);
echo "$d / $m /$y /$h /$i /$s";

One thought on “PHP codes for date and time”

Leave a Reply