本文整理汇总了PHP中strToTime函数的典型用法代码示例。如果您正苦于以下问题:PHP strToTime函数的具体用法?PHP strToTime怎么用?PHP strToTime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了strToTime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: displayDatetimeSpan
function displayDatetimeSpan($begin = null, $end = null)
{
$status = false;
if (!$begin) {
$begin = "now";
}
if (!$end) {
$end = "now";
}
$begin = date("U", strToTime($begin));
$end = date("U", strToTime($end));
$span = $end - $begin;
$days = floor($span / 86400);
// seconds in a day
$span = $span % 86400;
$hours = floor($span / 1440);
// minutes in a day
$span = $span % 1440;
$minutes = floor($span / 24);
// hours in a day
$span = $span % 24;
$seconds = floor($span / 1);
// days in a day. HA!
$hours = str_pad($hours, 2, "0", str_pad_left);
$minutes = str_pad($minutes, 2, "0", str_pad_left);
$seconds = str_pad($seconds, 2, "0", str_pad_left);
// $status = "$days days, $hours:$minutes:$seconds";
$status = "{$days} days, {$hours} hours, {$minutes} minutes, {$seconds} seconds";
return $status;
}
示例2: InSeconds
public function InSeconds()
{
$before = date_default_timezone_get();
date_default_timezone_set('UTC');
$seconds = strToTime($this->format('Y-m-d', 'H:i:s'));
date_default_timezone_set($before);
return $seconds;
}
示例3: getTime
/**
* Parses time string into time format used by plugin view
* @param string $timeStr
* @return string
*/
public static function getTime($timeStr)
{
if ($timeStr != "" && substr($timeStr, 0, strlen("0000-00-00")) != "0000-00-00") {
return date("d.m.Y / H:i", strToTime($timeStr));
} else {
return "";
}
}
示例4: InSeconds
public function InSeconds()
{
$before = date_default_timezone_get();
date_default_timezone_set('UTC');
$seconds = strToTime($this . ' 00:00:00');
date_default_timezone_set($before);
return $seconds;
}
示例5: outputShortDate
/**
* Shorten date
*
* @param date $date (optional)
* @return supplied (or current) date in format 2012-04-02 converted to string
*/
public static function outputShortDate($date = null)
{
if ($date == null) {
$date = Zend_Date::now();
}
$date = strToTime($date);
$date = new Zend_Date($date);
return $date->toString('y-MM-dd');
}
示例6: createDays
public static function createDays($schId)
{
$db = Database::getInstance();
$weekId = Week::getLastId();
$schedule = Schedule::getSchedule($schId);
$sql = "INSERT INTO day (weekId, startTime, shiftDate) VALUES (:weekId, :startTime, :shiftDate)";
for ($i = 0; $i < 7; $i++) {
$shift = date('Y-m-d', strToTime("+" . $i . " days", strToTime($schedule['startDate'])));
$result = $db->prepare($sql);
$result->execute(array(":weekId" => $weekId, ":startTime" => null, ":shiftDate" => $shift));
}
}
示例7: update
public static function update($iter)
{
$db = Database::getInstance();
$sql = "Update day SET startTime = :start WHERE id = :id";
$result = $db->prepare($sql);
if ($_POST['start_time_arr'][$iter] == "X") {
$start = null;
} else {
$start = date('H:i:s', strToTime($_POST['start_time_arr'][$iter]));
}
$result->execute(array(":start" => $start, ":id" => $_POST['day_id_arr'][$iter]));
}
示例8: period
/**
* Calculate period between two dates
* If the ending date is not supplied current datetime is taken
*
* @param string $start
* @param string $end (optional)
* @param bool $formatSeconds If set to false will not format seconds to string (optional)
* @return string time period
*/
public static function period($start, $end = null, $formatSeconds = true)
{
if ($end == null) {
$end = Zend_Date::now();
}
$start = new Zend_Date(strToTime($start));
$end = new Zend_Date(strToTime($end));
$difference = $start->sub($end);
if ($formatSeconds) {
return Game_View_Helper_Date::formatSeconds($difference->toValue());
} else {
return $difference->toValue();
}
}
示例9: smarty_modifier_newmark
function smarty_modifier_newmark($time, $format = '')
{
static $now, $period, $count;
$time = is_numeric($time) ? (int) $time : strToTime($time);
$retval = $format == '' ? '' : smarty_modifier_date_format($time, $format);
if ($now == null) {
$now = time();
$day = 60 * 60 * 24;
$period = array($day, $day * 7);
$count = count($period);
}
for ($i = 0; $i < $count; ++$i) {
if ($now < $time + $period[$i]) {
$retval .= sprintf('<em class="new%d">new!</em>', $i + 1);
break;
}
}
return $retval;
}
示例10: mailRemainderAction
public function mailRemainderAction()
{
$xDay = 3;
$countPerPeriod = 3;
$select = $this->getDb()->select()->from('User', 'id')->from('UserSettings')->where('User.createdAt > ?', date(DATE_ISO8601, strtotime(' - ' . $xDay . ' day')))->where('User.id = UserSettings.userId')->where('UserSettings.name = ?', Model_Verificator_Mail::SETTINGS_MAIL);
foreach ($select->query()->fetchAll(PDO::FETCH_COLUMN) as $userId) {
$user = $this->getTable('User')->find($userId)->current();
$sTime = $this->getTable('UserSettings')->getSettings(Model_Verificator_Mail::SETTINGS_CHANGET_AT, $user);
$this->getLog()->info($user->username . ' LastSend at: ' . $sTime->value);
$lastSendInPeriodPart = (time() - strToTime($sTime->value)) / (3600 * 24 * $xDay / $countPerPeriod);
if ($lastSendInPeriodPart >= 1) {
//no send to often
if ($this->getHelper('EmailVerification')->send($user)) {
$this->getLog()->info("Sent");
}
} else {
$this->getLog()->info("No sent: part " . number_format($lastSendInPeriodPart, 2));
}
}
}
示例11: getRangeOfDates
/**
* Given a starting date and a number of periods, return an array of dates
* where the first date is the last day of the month of the first period
* and every subsequent date is the last day of the following month
*
* @param String $date starting date
* @param int $count number of periods to compute
*
* @return array
*/
public static function getRangeOfDates($date, $count)
{
// the first date is the first of the following month
$month = date("m", strToTime($date)) + 1;
$year = date("Y", strToTime($date));
if ($month == 13) {
$month = 1;
$year++;
}
$dateTime = new DateTime($year . "-" . $month . "-01");
$dateTime->modify("-1 day");
$dates = array($dateTime->format("Y-m-d"));
// now, iterate $count - 1 times adding one month to each
for ($x = 1; $x < $count; $x++) {
$dateTime->modify("+1 day");
$dateTime->modify("+1 month");
$dateTime->modify("-1 day");
array_push($dates, $dateTime->format("Y-m-d"));
}
return $dates;
}
示例12: getBucket
public function getBucket($bucket, $prefix = null, $marker = null, $maxKeys = null)
{
$get = new S3Object('GET', $bucket, '');
if ($prefix !== null) {
$get->setParameter('prefix', $prefix);
}
if ($marker !== null) {
$get->setParameter('marker', $marker);
}
if ($maxKeys !== null) {
$get->setParameter('max-keys', $maxKeys);
}
$get = $get->getResponse($this);
$contents = array();
if (isset($get->body->Contents)) {
foreach ($get->body->Contents as $c) {
$contents[(string) $c->Key] = array('size' => (int) $c->Size, 'time' => strToTime((string) $c->LastModified), 'hash' => substr((string) $c->ETag, 1, -1));
}
}
return $get->code == 200 ? $contents : false;
}
示例13: mysql_query
<script src="js/jquery.js"></script>
<style type="text/css"></style>
<script src="js/jquery-ui.js"></script>
<script src="js/inputs.js"></script>
<script src="js/flot.js"></script>
<script src="js/functions.js"></script>
</head>
<body>
<div id="wrapper">
<!--USER PANEL-->
<?php
$login_query = mysql_query("SELECT * FROM {$server_adb}.account WHERE username = '" . mysql_real_escape_string($_SESSION["username"]) . "'");
$login2 = mysql_fetch_assoc($login_query);
$joindate = date("d.m.Y ", strToTime($login2['joindate']));
$uI = mysql_query("SELECT avatar FROM {$server_db}.users WHERE id = '" . $login2['id'] . "'");
$userInfo = mysql_fetch_assoc($uI);
?>
<div id="usr-panel">
<div class="av-overlay"></div>
<img src="<?php
echo $website['root'];
?>
images/avatars/2d/<?php
echo $account_extra['avatar'];
?>
" id="usr-av">
<div id="usr-info">
<span id="usr-name"><?php
echo $account_extra['firstName'];
示例14: __
<input type="submit" value="<?php
echo __('Report');
?>
" />
</form>
<hr />
<?php
if ($action == '') {
return;
}
#####################################################################
$t = (int) strToTime("{$month_d} months", $t);
$num_days = (int) date('t', $t);
$y = (int) date('Y', $t);
$m = (int) date('n', $t);
$today_day = (int) date('j', $t);
?>
<?php
/*
<div id="chart" style="position:absolute; left:189px; right:12px; top:14em; bottom:10px; overflow:scroll; border:1px solid #ccc; background:#fff;">
*/
?>
<script type="text/javascript">
function chart_fullscreen_toggle()
示例15: setCharts
//.........这里部分代码省略.........
switch ($type) {
case 'videodvd':
$query = "INSERT INTO {$tbl_1d_videodvd_charts} (\n\t\t\t\t\t\t\t\tChartID,\n\t\t\t\t\t\t\t\tNo,\n\t\t\t\t\t\t\t\tType,\n\t\t\t\t\t\t\t\tFilm,\n\t\t\t\t\t\t\t\tWeeks,\n\t\t\t\t\t\t\t\ttsWhen\n\t\t\t\t\t\t\t\t) VALUES (\n\t\t\t\t\t\t\t\t" . dbQuote($PARAM['PLACES']) . ",\n\t\t\t\t\t\t\t\t" . dbQuote($PARAM['NO']) . ",\n\t\t\t\t\t\t\t\t" . dbQuote($PARAM['TYPE']) . ",\n\t\t\t\t\t\t\t\t" . dbQuote($film) . ",\n\t\t\t\t\t\t\t\t" . dbQuote($PARAM['WEEKS']) . ",\n\t\t\t\t\t\t\t\t" . dbQuote($PARAM['WEEK']) . " )";
break;
case 'kino':
$query = "INSERT INTO {$tbl_1d_kino_charts} (\n\t\t\t\t\t\t\t\tChartID,\n\t\t\t\t\t\t\t\tNo,\n\t\t\t\t\t\t\t\tType,\n\t\t\t\t\t\t\t\tFilm,\n\t\t\t\t\t\t\t\tBoxOffice,\n\t\t\t\t\t\t\t\tcumBoxOffice,\n\t\t\t\t\t\t\t\tWeeks,\n\t\t\t\t\t\t\t\tScreens,\n\t\t\t\t\t\t\t\ttsWhen\n\t\t\t\t\t\t\t\t) VALUES (\n\t\t\t\t\t\t\t\t" . dbQuote($PARAM['PLACES']) . ",\n\t\t\t\t\t\t\t\t" . dbQuote($PARAM['NO']) . ",\n\t\t\t\t\t\t\t\t" . dbQuote($PARAM['TYPE']) . ",\n\t\t\t\t\t\t\t\t" . dbQuote($film) . ",\n\t\t\t\t\t\t\t\t" . dbQuote($PARAM['BO']) . ",\n\t\t\t\t\t\t\t\t" . dbQuote($PARAM['CBO']) . ",\n\t\t\t\t\t\t\t\t" . dbQuote($PARAM['WEEKS']) . ",\n\t\t\t\t\t\t\t\t" . dbQuote($PARAM['SCREENS']) . ",\n\t\t\t\t\t\t\t\t" . dbQuote($PARAM['WEEK']) . " )";
break;
}
} else {
switch ($type) {
case 'videodvd':
$query = "UPDATE {$tbl_1d_videodvd_charts} SET\n\t\t\t\t\t\t\t\tChartID = " . dbQuote($PARAM['PLACES']) . ",\n\t\t\t\t\t\t\t\tNo = " . dbQuote($PARAM['NO']) . ",\n\t\t\t\t\t\t\t\tType = " . dbQuote($PARAM['TYPE']) . ",\n\t\t\t\t\t\t\t\tFilm = " . dbQuote($film) . ",\n\t\t\t\t\t\t\t\tWeeks = " . dbQuote($PARAM['WEEKS']) . ",\n\t\t\t\t\t\t\t\ttsWhen = " . dbQuote($PARAM['WEEK']) . " \n\t\t\t\t\t\t\tWHERE ID = " . dbQuote($PARAM['id']);
break;
case 'kino':
$query = "UPDATE {$tbl_1d_kino_charts} SET\n\t\t\t\t\t\t\t\tChartID = " . dbQuote($PARAM['PLACES']) . ",\n\t\t\t\t\t\t\t\tNo = " . dbQuote($PARAM['NO']) . ",\n\t\t\t\t\t\t\t\tType = " . dbQuote($PARAM['TYPE']) . ",\n\t\t\t\t\t\t\t\tFilm = " . dbQuote($film) . ",\n\t\t\t\t\t\t\t\tBoxOffice = " . dbQuote($PARAM['BO']) . ",\n\t\t\t\t\t\t\t\tcumBoxOffice = " . dbQuote($PARAM['CBO']) . ",\n\t\t\t\t\t\t\t\tWeeks = " . dbQuote($PARAM['WEEKS']) . ",\n\t\t\t\t\t\t\t\tScreens = " . dbQuote($PARAM['SCREENS']) . ",\n\t\t\t\t\t\t\t\ttsWhen = " . dbQuote($PARAM['WEEK']) . " \n\t\t\t\t\t\t\tWHERE ID = " . dbQuote($PARAM['id']);
break;
}
}
$result = runQuery($query, 'setCharts()', 'SAVE_CHART');
$SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20107&PLACES=" . $PARAM['PLACES'] . "&WHEN=" . $PARAM['WEEK'] . "&WEEK=" . $PARAM['WEEK'];
printPage('_admin_done.htmlt');
return;
} else {
$SUBS['ERROR'] = fileParse('_admin_error.htmlt');
}
}
////----[Mrasnika's] Edition 12.10.2002
if ($PARAM['WHEN']) {
$PARAM['Year1'] = date('Y', $PARAM['WHEN']);
$PARAM['Month1'] = date('m', $PARAM['WHEN']);
$PARAM['Day1'] = date('d', $PARAM['WHEN']);
} else {
if ($PARAM['Day1'] && $PARAM['Month1'] && $PARAM['Year1']) {
$PARAM['WHEN'] = 1 + strToTime($PARAM['Day1'] . ' ' . $MONTHS2[$PARAM['Month1']] . ' ' . $PARAM['Year1']);
} else {
$PARAM['WHEN'] = getNextWeek();
}
}
$SUBS['PREV'] = week($PARAM['WHEN']) - 518400;
$SUBS['NEXT'] = week($PARAM['WHEN']) + 1026800;
//show charts records
switch ($type) {
case 'kino':
$query = "SELECT\t{$tbl_1d_kino_charts}.ID,\n\t\t\t\tChartID,\n\t\t\t\tNo,\n\t\t\t\tType,\n\t\t\t\tFilm,\n\t\t\t\tBoxOffice,\n\t\t\t\tcumBoxOffice,\n\t\t\t\tWeeks,\n\t\t\t\tScreens,\n\t\t\t\ttsWhen,\n\t\t\t\t\n\t\t\t\t{$tbl_1d_films}.Title,\n\t\t\t\t{$tbl_1d_films}.OriginalTitle\n\n\t\t\t\tFROM {$tbl_1d_kino_charts}\n\t\t\t\tLEFT JOIN {$tbl_1d_films}\n\t\t\t\t\tON {$tbl_1d_kino_charts}.Type = 'list'\n\t\t\t\t\t\tAND {$tbl_1d_films}.ID = {$tbl_1d_kino_charts}.Film\n\t\t\t\tWHERE {$tbl_1d_kino_charts}.ChartID = " . dbQuote($PARAM['PLACES']) . "\n\t\t\t\t\tAND {$tbl_1d_kino_charts}.tsWhen >= " . week($PARAM['WHEN']) . "\n\t\t\t\t\tAND {$tbl_1d_kino_charts}.tsWhen <= (" . week($PARAM['WHEN']) . "+604799)\n\t\t\t\tORDER BY {$tbl_1d_kino_charts}.No,\n\t\t\t\t\t{$tbl_1d_kino_charts}.BoxOffice";
break;
case 'videodvd':
$query = "SELECT\t{$tbl_1d_videodvd_charts}.ID,\n\t\t\t\tChartID,\n\t\t\t\tNo,\n\t\t\t\tType,\n\t\t\t\tFilm,\n\t\t\t\tWeeks,\n\t\t\t\tWeeks,\n\t\t\t\tWeeks,\n\t\t\t\tWeeks,\n\t\t\t\ttsWhen,\n\t\t\t\t\n\t\t\t\t{$tbl_1d_films}.Title,\n\t\t\t\t{$tbl_1d_films}.OriginalTitle\n\n\t\t\t\tFROM {$tbl_1d_videodvd_charts}\n\t\t\t\tLEFT JOIN {$tbl_1d_films}\n\t\t\t\t\tON {$tbl_1d_videodvd_charts}.Type = 'list'\n\t\t\t\t\t\tAND {$tbl_1d_films}.ID = {$tbl_1d_videodvd_charts}.Film\n\t\t\t\tWHERE {$tbl_1d_videodvd_charts}.ChartID = " . dbQuote($PARAM['PLACES']) . "\n\t\t\t\t\tAND {$tbl_1d_videodvd_charts}.tsWhen >= " . week($PARAM['WHEN']) . "\n\t\t\t\t\tAND {$tbl_1d_videodvd_charts}.tsWhen <= (" . week($PARAM['WHEN']) . "+604799)\n\t\t\t\tORDER BY {$tbl_1d_videodvd_charts}.No ";
break;
}
$result = runQuery($query, 'setCharts()', 'GET_CHART_RECORDS');
while ($row = db_fetch_row($result)) {
$SUBS['CHECK'] = $row[0];
$SUBS['CHARTID'] = $row[1];
$SUBS['NO2'] = sprintf("%02d", $row[2]);
if ($row[3] == 'list') {
if ($row[10]) {
$SUBS['TITLE'] = htmlEncode($row[10]);
} else {
$SUBS['TITLE'] = htmlEncode($row[11]);
}
$SUBS['MOVIE'] = $SUBS['ACTION'] . "?cmd=insertfilm&ID={$row['4']}";
} else {
$SUBS['TITLE'] = htmlEncode($row[4]);
$SUBS['MOVIE'] = "javascript:alert('{$MSG['20031']}')";
}
$SUBS['PRATI'] = $row[9];