It Returns date formatted according to given format and is an alias of DateTime::format()
Example
<?php
$date = date_create(‘2007-05-17’);
echo date_format($date, ‘Y-m-d H:i:s’);
?>
Output
2007-05-17 00:00:00
It Returns date formatted according to given format and is an alias of DateTime::format()
Example
<?php
$date = date_create(‘2007-05-17’);
echo date_format($date, ‘Y-m-d H:i:s’);
?>
Output
2007-05-17 00:00:00
CSScaffold is a CSS framework written in PHP. it uses PHP to extend CSS. The syntax looks and feels like CSS, except that you have some powerful abilities.
The best part is that all of this is done transparently. You can drop Scaffold into your site and you’ll instantly have access to all of its functionality. Scaffold requires a web server with PHP 5+ and Mod_rewrite should enabled if you want it work automatically .
<?php
$datetime1 = new DateTime(‘2009-5-17’);
$datetime2 = new DateTime(‘2012-5-17’);
$interval = $datetime1->diff($datetime2);
echo $interval->format(‘%R%a days’);
?>
Output
+1096 days
<?php
$date1 = date_create(‘2009-5-17’);
$date2 = date_create(‘2012-5-17’);
$interval = date_diff($date1, $date2);
echo $interval->format(‘%R%a days’);
?>
Output
+1096 days
Example
<?php
date_default_timezone_set(‘Asia/Culcutta’);
echo date_default_timezone_get();
?>
Output
Asia/Calcutta
Example
<?php
echo date_default_timezone_get();
?>
Output
Asia/Calcutta
<?php
$date = new DateTime();
$date->setDate(2011, 5, 17);
echo $date->format(‘Y-m-d’);
?>
echo $date->format(‘Y-m-d’);
?>
Output
2011-05-17
Its an alias of DateTime::setDate() and sets the date.
Example
<?php
$date = date_create();
date_date_set($date, 2011, 5, 17);
echo date_format($date, ‘Y-m-d’);
?>
echo $date->format(‘Y-m-d’);
?>
Output
2011-05-17
Example
<?php
try {
$date = new DateTime(‘2008-05-17’);
} catch (Exception $e) {
echo $e->getMessage();
exit(1);
}
echo $date->format(‘Y-m-d’);
?>
Output
2007-05-15
<?php
$date = date_create(‘2007-5-17’);
if (!$date) {
$e = date_get_last_errors();
foreach ($e[‘errors’] as $error) {
echo “$errorn”;
}
exit(1);
}
echo date_format($date, ‘Y-m-d’);
?>
Output
2007-05-15