Create new DateTime object from string(15) in PHP

Description

The following code shows how to create new DateTime object from string(15).

Example


<?php/* w  ww  . j  a  va 2s  .  co  m*/

$format = '!d';
$date = DateTime::createFromFormat($format, '15');
echo "Format: $format; " . $date->format('Y-m-d H:i:s') . "\n";
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone