Wednesday, January 6, 2016

Format Tanggal di PHP

<?php
$tanggal = "2016-01-01";

echo date("d F Y", strtotime($tanggal));    // 01 January 2016
echo "<BR>";
echo date("F j, Y, g:i a", strtotime($tanggal));                 // January 1, 2016, 12:00 am
echo "<BR>";
echo date("m.d.y", strtotime($tanggal));                         // 01.01.16
echo "<BR>";
echo date("j, n, Y, strtotime($tanggal)");                       // 6, 1, 2016, 2731Wed, 06 Jan 2016 11:12:27 +0700312016311201Asia/Jakarta(2016-01-01)
echo "<BR>";
echo date("Ymd", strtotime($tanggal));                           // 20160101
echo "<BR>";
echo date('h-i-s, j-m-y, it is w Day', strtotime($tanggal));     // 12-00-00, 1-01-16, 0031 0000 5 Friam16
echo "<BR>";
echo date('\i\t \i\s \t\h\e jS \d\a\y.', strtotime($tanggal));   // it is the 1st day.
echo "<BR>";
echo date("D M j G:i:s T Y", strtotime($tanggal));               // Fri Jan 1 0:00:00 WIB 2016
echo "<BR>";
echo date('H:m:s \m \i\s\ \m\o\n\t\h', strtotime($tanggal));     // 00:01:00 m is month
echo "<BR>";
echo date("H:i:s", strtotime($tanggal));                         // 00:00:00
echo "<BR>";
echo date("Y-m-d H:i:s", strtotime($tanggal));                   // 2016-01-01 00:00:00

?>

No comments:

Post a Comment