本文整理汇总了PHP中strtotime函数的典型用法代码示例。如果您正苦于以下问题:PHP strtotime函数的具体用法?PHP strtotime怎么用?PHP strtotime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了strtotime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test
public function test(CqmPatient $patient, $beginDate, $endDate)
{
// See if user has been a tobacco user before or simultaneosly to the encounter within two years (24 months)
$date_array = array();
foreach ($this->getApplicableEncounters() as $encType) {
$dates = Helper::fetchEncounterDates($encType, $patient, $beginDate, $endDate);
$date_array = array_merge($date_array, $dates);
}
// sort array to get the most recent encounter first
$date_array = array_unique($date_array);
rsort($date_array);
// go through each unique date from most recent
foreach ($date_array as $date) {
// encounters time stamp is always 00:00:00, so change it to 23:59:59 or 00:00:00 as applicable
$date = date('Y-m-d 23:59:59', strtotime($date));
$beginMinus24Months = strtotime('-24 month', strtotime($date));
$beginMinus24Months = date('Y-m-d 00:00:00', $beginMinus24Months);
// this is basically a check to see if the patient is an reported as an active smoker on their last encounter
if (Helper::check(ClinicalType::CHARACTERISTIC, Characteristic::TOBACCO_USER, $patient, $beginMinus24Months, $date)) {
return true;
} else {
if (Helper::check(ClinicalType::CHARACTERISTIC, Characteristic::TOBACCO_NON_USER, $patient, $beginMinus24Months, $date)) {
return false;
} else {
// nothing reported during this date period, so move on to next encounter
}
}
}
return false;
}
示例2: dateDiff
function dateDiff($start, $end)
{
$start_ts = strtotime($start);
$end_ts = strtotime($end);
$diff = $end_ts - $start_ts;
return round($diff / 86400);
}
示例3: getDatesBetween
public function getDatesBetween($dStart, $dEnd)
{
if ($dStart > $dEnd) {
$var = $dStart;
$dStart = $dEnd;
$dEnd = $var;
}
$iStart = strtotime($dStart);
$iEnd = strtotime($dEnd);
if (false === $iStart || false === $iEnd) {
return false;
}
$aStart = explode('-', $dStart);
$aEnd = explode('-', $dEnd);
if (count($aStart) !== 3 || count($aEnd) !== 3) {
return false;
}
if (false === checkdate($aStart[1], $aStart[2], $aStart[0]) || false === checkdate($aEnd[1], $aEnd[2], $aEnd[0]) || $iEnd < $iStart) {
return false;
}
for ($i = $iStart; $i < $iEnd + 86400; $i = strtotime('+1 day', $i)) {
$sDateToArr = strftime('%Y-%m-%d', $i);
$sYear = substr($sDateToArr, 0, 4);
$sMonth = substr($sDateToArr, 5, 2);
//$aDates[$sYear][$sMonth][]=$sDateToArr;
$aDates[] = $sDateToArr;
}
if (isset($aDates) && !empty($aDates)) {
return $aDates;
} else {
return false;
}
}
示例4: collectData
public function collectData(array $param)
{
$html = $this->file_get_html('http://www.maliki.com/') or $this->returnError('Could not request Maliki.', 404);
$count = 0;
$latest = 1;
$latest_title = "";
$latest = $html->find('div.conteneur_page a', 1)->href;
$latest_title = $html->find('div.conteneur_page img', 0)->title;
function MalikiExtractContent($url)
{
$html2 = $this->file_get_html($url);
$text = 'http://www.maliki.com/' . $html2->find('img', 0)->src;
$text = '<img alt="" src="' . $text . '"/><br>' . $html2->find('div.imageetnews', 0)->plaintext;
return $text;
}
$item = new \Item();
$item->uri = 'http://www.maliki.com/' . $latest;
$item->title = $latest_title;
$item->timestamp = time();
$item->content = MalikiExtractContent($item->uri);
$this->items[] = $item;
foreach ($html->find('div.boite_strip') as $element) {
if (!empty($element->find('a', 0)->href) and $count < 3) {
$item = new \Item();
$item->uri = 'http://www.maliki.com/' . $element->find('a', 0)->href;
$item->title = $element->find('img', 0)->title;
$item->timestamp = strtotime(str_replace('/', '-', $element->find('span.stylepetit', 0)->innertext));
$item->content = MalikiExtractContent($item->uri);
$this->items[] = $item;
$count++;
}
}
}
示例5: calculateGFRResult
function calculateGFRResult()
{
$tmpArr = array();
$tmpArr[] = date('Y-m-d H:i:s');
//observation time
$tmpArr[] = 'GFR (CALC)';
//desc
$gender = NSDR::populate($this->_patientId . "::com.clearhealth.person.displayGender");
$crea = NSDR::populate($this->_patientId . "::com.clearhealth.labResults[populate(@description=CREA)]");
$genderFactor = null;
$creaValue = null;
$personAge = null;
$raceFactor = 1;
switch ($gender[key($gender)]) {
case 'M':
$genderFactor = 1;
break;
case 'F':
$genderFactor = 0.742;
break;
}
if ((int) strtotime($crea['observation_time']) >= strtotime('now - 60 days') && strtolower($crea[key($crea)]['units']) == 'mg/dl') {
$creaValue = $crea[key($crea)]['value'];
}
$person = new Person();
$person->personId = $this->_patientId;
$person->populate();
if ($person->age > 0) {
$personAge = $person->age;
}
$personStat = new PatientStatistics();
$personStat->personId = $this->_patientId;
$personStat->populate();
if ($personStat->race == "AFAM") {
$raceFactor = 1.21;
}
$gfrValue = "INC";
if ($personAge > 0 && $creaValue > 0) {
$gfrValue = "" . (int) round(pow($creaValue, -1.154) * pow($personAge, -0.203) * $genderFactor * $raceFactor * 186);
}
trigger_error("gfr:: " . $gfrValue, E_USER_NOTICE);
$tmpArr[] = $gfrValue;
// lab value
$tmpArr[] = 'mL/min/1.73 m2';
//units
$tmpArr[] = '';
//ref range
$tmpArr[] = '';
//abnormal
$tmpArr[] = 'F';
//status
$tmpArr[] = date('Y-m-d H:i:s') . '::' . '0';
// observationTime::(boolean)normal; 0 = abnormal, 1 = normal
$tmpArr[] = '0';
//sign
//$this->_calcLabResults[uniqid()] = $tmpArr;
$this->_calcLabResults[1] = $tmpArr;
// temporarily set index to one(1) to be able to include in selected lab results
return $tmpArr;
}
示例6: PMA_printGitRevision
/**
* Prints details about the current Git commit revision
*
* @return void
*/
function PMA_printGitRevision()
{
if (!$GLOBALS['PMA_Config']->get('PMA_VERSION_GIT')) {
$response = PMA_Response::getInstance();
$response->isSuccess(false);
return;
}
// load revision data from repo
$GLOBALS['PMA_Config']->checkGitRevision();
// if using a remote commit fast-forwarded, link to GitHub
$commit_hash = substr($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH'), 0, 7);
$commit_hash = '<strong title="' . htmlspecialchars($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_MESSAGE')) . '">' . $commit_hash . '</strong>';
if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTECOMMIT')) {
$commit_hash = '<a href="' . PMA_linkURL('https://github.com/phpmyadmin/phpmyadmin/commit/' . $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH')) . '" target="_blank">' . $commit_hash . '</a>';
}
$branch = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH');
if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTEBRANCH')) {
$branch = '<a href="' . PMA_linkURL('https://github.com/phpmyadmin/phpmyadmin/tree/' . $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH')) . '" target="_blank">' . $branch . '</a>';
}
if ($branch !== false) {
$branch = sprintf(__('%1$s from %2$s branch'), $commit_hash, $branch);
} else {
$branch = $commit_hash . ' (' . __('no branch') . ')';
}
$committer = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITTER');
$author = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_AUTHOR');
PMA_printListItem(__('Git revision:') . ' ' . $branch . ',<br /> ' . sprintf(__('committed on %1$s by %2$s'), PMA_Util::localisedDate(strtotime($committer['date'])), '<a href="' . PMA_linkURL('mailto:' . $committer['email']) . '">' . htmlspecialchars($committer['name']) . '</a>') . ($author != $committer ? ', <br />' . sprintf(__('authored on %1$s by %2$s'), PMA_Util::localisedDate(strtotime($author['date'])), '<a href="' . PMA_linkURL('mailto:' . $author['email']) . '">' . htmlspecialchars($author['name']) . '</a>') : ''), 'li_pma_version_git', null, null, null);
}
示例7: updateCurrencies
public function updateCurrencies()
{
if (extension_loaded('curl')) {
$data = array();
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency WHERE code != '" . $this->db->escape($this->config->get('config_currency')) . "' AND date_modified > '" . date(strtotime('-1 day')) . "'");
foreach ($query->rows as $result) {
$data[] = $this->config->get('config_currency') . $result['code'] . '=X';
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://download.finance.yahoo.com/d/quotes.csv?s=' . implode(',', $data) . '&f=sl1&e=.csv');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$content = curl_exec($ch);
curl_close($ch);
$lines = explode("\n", trim($content));
foreach ($lines as $line) {
$currency = substr($line, 4, 3);
$value = substr($line, 11, 6);
if ((double) $value) {
$this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '" . (double) $value . "', date_modified = NOW() WHERE code = '" . $this->db->escape($currency) . "'");
}
}
$this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '1.00000', date_modified = NOW() WHERE code = '" . $this->db->escape($this->config->get('config_currency')) . "'");
$this->cache->delete('currency');
}
}
示例8: getRec
/**
* Obtiene el listado de grabaciones por cada sala en un intervalo de fechas
* @return json
*/
function getRec()
{
$rec = $_POST['sco_id'];
$records = $this->cliente->getRecordings($rec);
$begrecord = $_POST['inicio'] == "" ? $_POST['tbegin'] : strtotime($_POST['inicio']);
$endrecord = $_POST['finald'] == "" ? date('Y-m-d') : $_POST['finald'];
if (!empty($records['recordings'])) {
if ($records['recordings']['sco'][0]) {
$data = $records['recordings']['sco'];
} else {
$data[] = $records['recordings']['sco'];
}
} else {
$recData->data[]['name'] = 'Sin registros';
echo json_encode($recData);
exit;
}
foreach ($data as $key => $value) {
$acl_id = $value['@attributes']['sco-id'];
$this->cliente->setPublicRecordings($acl_id);
$date_created = strtotime(date('Y-m-d', strtotime($value['date-created'])));
if ($date_created >= $begrecord && $date_created <= strtotime($endrecord)) {
$recData->data[] = $data[$key];
}
}
echo json_encode($recData);
}
示例9: refresh
public function refresh($force = false)
{
if (extension_loaded('curl')) {
$data = array();
if ($force) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency WHERE code != '" . $this->db->escape($this->config->get('config_currency')) . "'");
} else {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency WHERE code != '" . $this->db->escape($this->config->get('config_currency')) . "' AND date_modified < '" . $this->db->escape(date('Y-m-d H:i:s', strtotime('-1 day'))) . "'");
}
foreach ($query->rows as $result) {
$data[] = $this->config->get('config_currency') . $result['code'] . '=X';
}
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://download.finance.yahoo.com/d/quotes.csv?s=' . implode(',', $data) . '&f=sl1&e=.csv');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
$content = curl_exec($curl);
curl_close($curl);
$lines = explode("\n", trim($content));
foreach ($lines as $line) {
$currency = utf8_substr($line, 4, 3);
$value = utf8_substr($line, 11, 6);
if ((double) $value) {
$this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '" . (double) $value . "', date_modified = '" . $this->db->escape(date('Y-m-d H:i:s')) . "' WHERE code = '" . $this->db->escape($currency) . "'");
}
}
$this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '1.00000', date_modified = '" . $this->db->escape(date('Y-m-d H:i:s')) . "' WHERE code = '" . $this->db->escape($this->config->get('config_currency')) . "'");
$this->cache->delete('currency');
}
}
示例10: is_datetime
function is_datetime($date)
{
if ($date == date('Y-m-d H:i:s', strtotime($date))) {
return true;
}
return false;
}
示例11: updatePost
public function updatePost($id, $created, $source, $title)
{
$data = array('source' => $source, 'title' => $title);
// Valid date given (YYYY-MM-DD)?
if (preg_match('/^\\d{4}.\\d{2}.\\d{2}.+\\d{2}.\\d{2}$/', $created) && strtotime($created)) {
$data['created'] = $created;
$initial = $this->db->getRow('SELECT UNIX_TIMESTAMP(created) as created, image, thumb
FROM ' . ASAPH_TABLE_POSTS . '
WHERE id = :1', $id);
// OK, this sucks hard. If the date changed, we may have to move the thumb and image
// into another path and make sure to not overwrite any other imagess.
$initialPath = date('Y/m', $initial['created']);
$newPath = date('Y/m', strtotime($created));
if ($initialPath != $newPath && !empty($initial['thumb'])) {
$newImageDir = ASAPH_PATH . Asaph_Config::$images['imagePath'] . $newPath;
$newThumbDir = ASAPH_PATH . Asaph_Config::$images['thumbPath'] . $newPath;
$newImageName = $this->getUniqueFileName($newImageDir, $initial['image']);
$newThumbName = $this->getUniqueFileName($newThumbDir, $initial['thumb']);
$initialImagePath = ASAPH_PATH . Asaph_Config::$images['imagePath'] . $initialPath . '/' . $initial['image'];
$initialThumbPath = ASAPH_PATH . Asaph_Config::$images['thumbPath'] . $initialPath . '/' . $initial['thumb'];
$newImagePath = $newImageDir . '/' . $newImageName;
$newThumbPath = $newThumbDir . '/' . $newThumbName;
$data['image'] = $newImageName;
$data['thumb'] = $newThumbName;
if (!$this->mkdirr($newImageDir) || !$this->mkdirr($newThumbDir) || !@rename($initialImagePath, $newImagePath) || !@rename($initialThumbPath, $newThumbPath)) {
return false;
}
}
}
$this->db->updateRow(ASAPH_TABLE_POSTS, array('id' => $id), $data);
return true;
}
示例12: index
public function index()
{
if ($this->open_sign == 0) {
//未开启活动提示
}
$set_id = M('sign_set')->where(array('token' => session('token')))->getField('id');
// $where = array('set_id'=>$set_id);
$where = array();
$user_name = $this->_post('user_name', 'htmlspecialchars,trim');
$sort = $this->_post('sort', 'trim');
$startdate = strtotime($this->_post('startdate', 'trim'));
$enddate = strtotime($this->_post('enddate', 'trim'));
if ($startdate && $enddate) {
$where['time'] = array(array('gt', $startdate), array('lt', $enddate), 'and');
}
if ($user_name) {
$where['user_name'] = array('like', '%' . $user_name . '%');
}
if (empty($sort)) {
$order = 'time desc';
} else {
$order = 'time ' . $sort;
}
$count = $this->sign_db->where($where)->count();
$Page = new Page($count, 12);
$list = $this->sign_db->where($where)->order($order)->limit($Page->firstRow . ',' . $Page->listRows)->select();
$this->assign('search', array('startdate' => $startdate, 'enddate' => $enddate, 'sort' => $sort));
$this->assign('page', $Page->show());
$this->assign('list', $list);
$this->assign('listinfo', 1);
$this->display();
}
示例13: created_on
public function created_on()
{
if (preg_match('/Created On :[\\s]+(.*?)\\n/', $this->body, $match)) {
return strtotime($match[1]);
}
return null;
}
示例14: updated_on
public function updated_on()
{
if (preg_match('/Last Updated On:(.*?)\\n/', $this->body, $match)) {
return strtotime($match[1]);
}
return null;
}
示例15: gdlr_print_hotel_availability_item
function gdlr_print_hotel_availability_item($settings = array())
{
$item_id = empty($settings['page-item-id']) ? '' : ' id="' . $settings['page-item-id'] . '" ';
global $gdlr_spaces, $hotel_option;
$margin = !empty($settings['margin-bottom']) && $settings['margin-bottom'] != $gdlr_spaces['bottom-blog-item'] ? 'margin-bottom: ' . $settings['margin-bottom'] . ';' : '';
$margin_style = !empty($margin) ? ' style="' . $margin . '" ' : '';
$current_date = current_time('Y-m-d');
$next_date = date('Y-m-d', strtotime($current_date . "+1 days"));
$value = array('gdlr-check-in' => $current_date, 'gdlr-night' => 1, 'gdlr-check-out' => $next_date, 'gdlr-room-number' => 1, 'gdlr-adult-number' => 1, 'gdlr-children-number' => 0);
$ret = gdlr_get_item_title($settings);
$ret .= '<div class="gdlr-hotel-availability-wrapper';
if (!empty($hotel_option['enable-hotel-branch']) && $hotel_option['enable-hotel-branch'] == 'enable') {
$ret .= ' gdlr-hotel-branches-enable';
}
$ret .= '" ' . $margin_style . $item_id . ' >';
$ret .= '<form class="gdlr-hotel-availability gdlr-item" id="gdlr-hotel-availability" method="post" action="' . esc_url(add_query_arg(array($hotel_option['booking-slug'] => ''), home_url('/'))) . '" >';
if (!empty($hotel_option['enable-hotel-branch']) && $hotel_option['enable-hotel-branch'] == 'enable') {
$ret .= gdlr_get_reservation_branch_combobox(array('title' => __('Hotel Branches', 'gdlr-hotel'), 'slug' => 'gdlr-hotel-branches', 'id' => 'gdlr-hotel-branches', 'value' => ''));
}
$ret .= gdlr_get_reservation_datepicker(array('title' => __('Check In', 'gdlr-hotel'), 'slug' => 'gdlr-check-in', 'id' => 'gdlr-check-in', 'value' => $value['gdlr-check-in']));
$ret .= gdlr_get_reservation_combobox(array('title' => __('Night', 'gdlr-hotel'), 'slug' => 'gdlr-night', 'id' => 'gdlr-night', 'value' => $value['gdlr-night']));
$ret .= gdlr_get_reservation_datepicker(array('title' => __('Check Out', 'gdlr-hotel'), 'slug' => 'gdlr-check-out', 'id' => 'gdlr-check-out', 'value' => $value['gdlr-check-out']));
$ret .= gdlr_get_reservation_combobox(array('title' => __('Adults', 'gdlr-hotel'), 'slug' => 'gdlr-adult-number', 'id' => '', 'value' => $value['gdlr-adult-number'], 'multiple' => true));
$ret .= gdlr_get_reservation_combobox(array('title' => __('Children', 'gdlr-hotel'), 'slug' => 'gdlr-children-number', 'id' => '', 'value' => $value['gdlr-children-number'], 'multiple' => true));
$ret .= '<div class="gdlr-hotel-availability-submit" >';
$ret .= '<input type="hidden" name="hotel_data" value="1" >';
$ret .= '<input type="hidden" name="gdlr-room-number" value="1" />';
$ret .= '<input type="submit" class="gdlr-reservation-bar-button gdlr-button with-border" value="' . __('Check Availability', 'gdlr-hotel') . '" >';
$ret .= '</div>';
$ret .= '<div class="clear"></div>';
$ret .= '</form>';
$ret .= '</div>';
return $ret;
}