July 31, 2012

How to get date from the datetime in php

How to get date from the datetime in php


$result = mysql_query("SELECT `datetime` FROM `table`");
$row = mysql_fetch_row($result);
$date = date_create($row[0]);

echo date_format($date, 'Y-m-d H:i:s');

echo date_format($date, 'd/m/Y H:i:s');

echo date_format($date, 'd/m/y');

echo date_format($date, 'g:i A');

echo date_format($date, 'G:ia');

echo date_format($date, 'g:ia \o\n l jS F Y');

No comments:

Post a Comment

Integrating Google reCAPTCHA v3 in HTML Form with PHP

  What is Google reCAPTCHA v3? Google reCAPTCHA is a free service that helps protect websites from spam and abuse. reCAPTCHA v3 is the lates...