22 March, 2014

Convert timestamp to readable date time php

Convert hasil time() pada php ke tahun, bulan, jam, menit, detik


$time = time() // you have 1299446702 in time

$year = $time/31556926 % 12;  // to get year

$week = $time / 604800 % 52;  // to get weeks

$hour = $time / 3600 % 24;    // to get hours

$minute = $time / 60 % 60;    // to get minutes

$second = $time % 60;         // to get seconds



example :

echo date('m/d/Y', 1299446702);

2 comments: