PHP code example of yalesov / date-time-parser
1. Go to this page and download the library: Download yalesov/date-time-parser library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yalesov / date-time-parser example snippets
use Yalesov\DateTimeParser\Parser;
$datetime = Parser::parseDateTime('19961022T140000+0800');
// $datetime['year'] = '1996';
// $datetime['month'] = '10';
// $datetime['day'] = '22';
// $datetime['hour'] = '14';
// $datetime['minute'] = '00';
// $datetime['second'] = '00';
// $datetime['timezone'] = '+0800';
$datetime = Parser::parseDateTime('---22T14');
// $datetime['year'] = null;
// $datetime['month'] = null;
// $datetime['day'] = '22';
// $datetime['hour'] = '14';
// $datetime['minute'] = null;
// $datetime['second'] = null;
// $datetime['timezone'] = null;
public static function parseDateTime($datetime)
public static function parseDate($date)
public static function parseTime($time)
use Yalesov\DateTimeParser\Parser;
$expr = Parser::createDateTime('1996', '10', '22', '14', '00', '00', '+0800');
// $expr = '19961022T140000+0800';
$expr = Parser::createDateTime(null, null, '22', '14', null, null, null);
// $expr = '---22T14';
public static function createDateTime(
$year = null, $month = null, $day = null,
$hour = null, $minute = null, $second = null, $timezone = null)
public static function createDate($year = null, $month = null, $day = null)
public static function createTime($hour = null, $minute = null, $second = null, $timezone = null)
public static function createTimestamp(
$year = null, $month = null, $day = null,
$hour = null, $minute = null, $second = null, $timezone = null)