本文整理汇总了PHP中DateTime::createfromformat方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTime::createfromformat方法的具体用法?PHP DateTime::createfromformat怎么用?PHP DateTime::createfromformat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTime
的用法示例。
在下文中一共展示了DateTime::createfromformat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: header
<?php
header("content-type: text/html; charset: utf-8");
$offset = 365 * 24 * 60 * 60;
$expire = "expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT";
#header($expire);
if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
ob_start("ob_gzhandler");
} else {
ob_start();
}
require_once 'universal/universalinclude.php';
$datein = filter_input(INPUT_GET, 'd', FILTER_SANITIZE_NUMBER_INT);
if ($datein !== null) {
$date0 = DateTime::createfromformat('Ymd', $datein);
} else {
$date0 = new DateTime('now', new DateTimeZone('America/Montreal'));
if ($date0->format('G') < 13) {
$date0->sub(new DateInterval('P1D'));
}
$datein = $date0->format('Ymd');
}
$dateDisp = $date0->format('M j, Y');
$dateDisp2 = $date0->format('l, F j, Y');
$month = $date0->format('n');
$year = $date0->format('Y');
$date = $date0->format('Y-m-d');
if ($month < 8) {
$yID = (string) ($year - 1);
$yID .= $year;
} else {
示例2: ob_start
#header($expire);
if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
ob_start("ob_gzhandler");
} else {
ob_start();
}
require_once 'universal/universalinclude.php';
$game = intval(filter_input(INPUT_GET, 'g', FILTER_SANITIZE_NUMBER_INT));
$season = intval(filter_input(INPUT_GET, 's', FILTER_SANITIZE_NUMBER_INT));
$year = intval(filter_input(INPUT_GET, 'y', FILTER_SANITIZE_NUMBER_INT));
# `games`: GAME DATA
$gamedata = "SELECT * FROM `games` WHERE `gameNo`=" . $game . " AND `seasonNo`=" . $season . " AND year=" . $year;
$gamedata = $dbconnect->fetch1($gamedata);
$away = $gamedata['awayTeam'];
$home = $gamedata['homeTeam'];
$date = DateTime::createfromformat('Y-m-d', $gamedata['date']);
$date = $date->format('M j, Y');
# `box`: GAME PLAYERS
$pkeys = array('G', 'A', 'Points', 'TOI', 'PlusMinus', 'ShotAttempts', 'PIM', 'HIT', 'GPP', 'FOT', 'FOW', 'GIVE', 'TAKE', 'AgCHANCEEV', 'AgCHANCEEVG', 'AgCHANCEPP', 'AgCHANCEPPG', 'AgCHANCESH', 'AgCHANCESHG', 'totalOff', 'totalNeu', 'totalDef');
$gkeys = array('W', 'L', 'OTL', 'SOL', 'SOL', 'SVP', 'SA', 'GA');
$sqlP = $keyDB->keyData($pkeys, true);
$sqlG = $keyDB->keyData($gkeys, true);
$boxdata = "SELECT a.`playerID`, `playerTeam`, `playerPos`, `gameNo`, seasonNo, totG, totA,\n " . $sqlP . ",\n " . $sqlG . "\n FROM `box" . $year . "` a\n LEFT JOIN (SELECT `playerID`, SUM(`G`) as 'totG', SUM(`A`) as 'totA'\n FROM `box" . $year . "`\n WHERE `gameNo`<" . $game . "\n AND `seasonNo`=" . $season . "\n GROUP BY `playerID`) b\n ON a.playerID = b.playerID\n WHERE `gameNo`=" . $game . "\n AND `seasonNo`=" . $season . "\n GROUP BY `playerID";
$boxdata = $dbconnect->fetchTotal2($boxdata);
$idQ = '';
foreach ($boxdata as $id => $boxplayer) {
$idQ .= "`playerID`=" . $id . " OR ";
if ($boxplayer[0]['playerTeam'] === $away) {
$playerlist['away']['game'][$id] = $boxplayer[0]['TOI'];
if ($boxplayer[0]['playerPos'] === 'G') {
$playerlist['away']['gameG'][$id] = $boxplayer[0]['TOI'];