当前位置: 首页>>代码示例>>PHP>>正文


PHP idate函数代码示例

本文整理汇总了PHP中idate函数的典型用法代码示例。如果您正苦于以下问题:PHP idate函数的具体用法?PHP idate怎么用?PHP idate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了idate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: day_time

function day_time($time = false)
{
    if ($time === false) {
        $time = time();
    }
    return mktime(0, 0, 0, idate('m', $time), idate('d', $time), idate('Y', $time));
}
开发者ID:soldair,项目名称:solumLite,代码行数:7,代码来源:libgeneral.php

示例2: word

 public static function word($from, $now = null)
 {
     if (null === $now) {
         $now = time();
     }
     $between = $now - $from;
     if ($between > 0 && $between < 86400 && idate('d', $from) == idate('d', $now)) {
         if ($between < 3600 && idate('H', $from) == idate('H', $now)) {
             if ($between < 60 && idate('i', $from) == idate('i', $now)) {
                 $second = idate('s', $now) - idate('s', $from);
                 if (0 == $second) {
                     return '刚刚';
                 } else {
                     return sprintf('%d秒前', $second);
                 }
             }
             $min = idate('i', $now) - idate('i', $from);
             return sprintf('%d分钟前', $min);
         }
         $hour = idate('H', $now) - idate('H', $from);
         return sprintf('%d小时前', $hour);
     }
     if ($between > 0 && $between < 172800 && (idate('z', $from) + 1 == idate('z', $now) || idate('z', $from) > 2 + idate('z', $now))) {
         return sprintf('昨天 %s', date('H:i', $from));
     }
     if ($between > 0 && $between < 604800 && idate('W', $from) == idate('W', $now)) {
         $day = intval($between / (3600 * 24));
         return sprintf('%d天前', $day);
     }
     if ($between > 0 && $between < 31622400 && idate('Y', $from) == idate('Y', $now)) {
         return date('n月j日', $from);
     }
     return date('Y年m月d日', $from);
 }
开发者ID:miaokuan,项目名称:wee,代码行数:34,代码来源:Date.php

示例3: onMessage

 /**
  * 有消息时触发该方法
  * @param int $client_id 发消息的client_id
  * @param string $message 消息
  * @return void
  */
 public static function onMessage($client_id, $message)
 {
     $db = \Lib\Db::instance('tc504');
     $nowtime = idate("U");
     $ok = "right";
     $error = "error";
     $sqlok = "sql right!";
     $sqlerror = "sql error!";
     if ($message[0] == '{') {
         $message = JsonProtocol::decode($message);
         $sqldidian = $message['ID'];
         $sqlshidu = $message['humidity'];
         $sqlwendu = $message['temperature'];
         $insert_id = $db->insert('wenshidu')->cols(array('didian' => $sqldidian, 'shidu' => $sqlshidu, 'wendu' => $sqlwendu, 'time' => $nowtime))->query();
         GateWay::sendToClient($client_id, TextProtocol::encode($insert_id));
     } else {
         $message = TextProtocol::decode($message);
         $commend = trim($message);
         $ret = $db->select('ui_cardid')->from('tbl_user')->where("ui_cardid = '{$commend}' ")->single();
         if ($commend === $ret) {
             $insert_id = $db->insert('tbl_log')->cols(array('log_card' => $commend, 'log_time' => $nowtime))->query();
             if ($insert_id === 1) {
                 GateWay::sendToClient($client_id, TextProtocol::encode($sqlok));
             } else {
                 GateWay::sendToClient($client_id, TextProtocol::encode($sqlerror));
             }
         } else {
             GateWay::sendToClient($client_id, TextProtocol::encode($error));
         }
     }
 }
开发者ID:eseawind,项目名称:qian_dao,代码行数:37,代码来源:Event.php

示例4: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     // TODO: These should be user-based and navigable in the interface.
     $year = idate('Y');
     $month = idate('m');
     $holidays = id(new PhabricatorCalendarHoliday())->loadAllWhere('day BETWEEN %s AND %s', "{$year}-{$month}-01", "{$year}-{$month}-31");
     $statuses = id(new PhabricatorUserStatus())->loadAllWhere('dateTo >= %d AND dateFrom <= %d', strtotime("{$year}-{$month}-01"), strtotime("{$year}-{$month}-01 next month"));
     $month_view = new AphrontCalendarMonthView($month, $year);
     $month_view->setUser($user);
     $month_view->setHolidays($holidays);
     $phids = mpull($statuses, 'getUserPHID');
     $handles = $this->loadViewerHandles($phids);
     foreach ($statuses as $status) {
         $event = new AphrontCalendarEventView();
         $event->setEpochRange($status->getDateFrom(), $status->getDateTo());
         $name_text = $handles[$status->getUserPHID()]->getName();
         $status_text = $status->getTextStatus();
         $event->setUserPHID($status->getUserPHID());
         $event->setName("{$name_text} ({$status_text})");
         $event->setDescription($status->getStatusDescription($user));
         $month_view->addEvent($event);
     }
     return $this->buildStandardPageResponse(array('<div style="padding: 2em;">', $month_view, '</div>'), array('title' => 'Calendar'));
 }
开发者ID:rudimk,项目名称:phabricator,代码行数:26,代码来源:PhabricatorCalendarBrowseController.php

示例5: __construct

 public function __construct($email_id)
 {
     $this->_email_id = $email_id;
     //ISO Week number of the current year
     $week_number = idate("W");
     $year = idate("Y");
     $month = idate("m");
     $last_day_of_month = idate('t');
     $today = new \DateTime();
     $start_of_month = clone $today;
     $start_of_month->setDate($year, $month, 1);
     $start_of_month->setTime(0, 0, 1);
     $end_of_month = clone $today;
     $end_of_month->setDate($year, $month, $last_day_of_month);
     $end_of_month->setTime(23, 59, 59);
     $start_of_week = clone $today;
     $start_of_week->setISODate($year, $week_number);
     $start_of_week->setTime(0, 0, 0);
     $end_of_week = clone $start_of_week;
     $date_interval = new \DateInterval("P6D");
     $end_of_week->add($date_interval);
     $end_of_week->setTime(23, 59, 59);
     $this->_today = $today;
     $this->_start_of_month = $start_of_month;
     $this->_end_of_month = $end_of_month;
     $this->_start_of_week = $start_of_week;
     $this->_end_of_week = $end_of_week;
 }
开发者ID:viggi2004,项目名称:datacollector-backend,代码行数:28,代码来源:LeaderBoard.php

示例6: __construct

 function __construct()
 {
     require_once 'Date.php';
     global $pref;
     $this->time = new Date();
     // Convert this original time to UTC so we can get an accurate conversion
     $localtimeOffset = idate('Z');
     // Subtract or add the perfect amount of hours
     $s = $localtimeOffset / 3600;
     $hour = $this->time->hour - $s;
     $this->time->setHour($hour);
     $this->time->convertTZbyID($pref->prefs['timezone']);
     $this->timeZone = $this->time->tz;
     $this->offset = $this->timeZone->offset / 1000;
     // Set available time zones
     $this->availableZones = $this->timeZone->getAvailableIDs();
     // Set now
     $this->now['second'] = $this->time->getSecond();
     $this->now['minute'] = $this->time->getMinute();
     $this->now['hour'] = $this->time->getHour();
     $this->now['day'] = $this->time->getDay();
     $this->now['month'] = $this->time->getMonth();
     $this->now['year'] = $this->time->getYear();
     // Set current GMT timestamp
     $this->timestamp = $this->make($this->now['second'], $this->now['minute'], $this->now['hour'], $this->now['day'], $this->now['month'], $this->now['year']);
 }
开发者ID:BackupTheBerlios,项目名称:acal-svn,代码行数:26,代码来源:time.php

示例7: mysql_to_json

function mysql_to_json($connection_name, $table_name, $file_name)
{
    // Verifies that table name and connection to MySQL exist.
    if (!$connection_name || !$table_name) {
        return false;
    }
    // If the user did not enter a desired file name, a unique one will be initiated.
    if (!$file_name) {
        $file_name = "new_json_file" . idate("U");
    }
    // Type casts input variables to strings in the case that the user entered a different variable type.
    $table_name = string($table_name);
    $file_name = string($file_name);
    // Query data from MySQL server.
    $data_query = "SELECT * FROM {$table_name}";
    $data_request = @mysqli_query($connection_name, $data_query);
    // Insert queried data into an array.
    $data_saved[] = array();
    while ($entry = mysqli_fetch_assoc($data_request)) {
        $data_saved[] = $entry;
    }
    // Copy array data to file.
    $file_wrtie = fopen($file_name, 'w');
    fwrite($file_write, json_encode($data_saved));
    fclose($file_write);
    // Return true to let the user know that everything ran successfully.
    return true;
}
开发者ID:jimmygrzybek,项目名称:MySQL-Table-to-JSON,代码行数:28,代码来源:json_mysql_converter.php

示例8: getDST

 protected function getDST($timestamp)
 {
     if (idate('I', $timestamp)) {
         return 3600;
     }
     return 0;
 }
开发者ID:Stony-Brook-University,项目名称:doitsbu,代码行数:7,代码来源:DateHandler.php

示例9: add

 public function add()
 {
     //checks if data posted by user is valid; helps prevent SQL Injection
     $valid = true;
     //16 digit number needed for card
     if (preg_match("/^(\\d{16})+\$/", $_POST["card"]) === 0) {
         $_SESSION["cardBorder"] = "1px solid #aa0000";
         $_SESSION["cardWarn"] = true;
         $valid = false;
     }
     //checks if expiry date hasn't already passed
     if ($_POST["expYear"] == idate("y")) {
         if ($_POST["expMonth"] <= idate("m")) {
             $_SESSION["expBorder"] = "1px solid #aa0000";
             $_SESSION["expWarn"] = true;
             $valid = false;
         }
     }
     //3 digit number needed for card security number
     if (preg_match("/^(\\d{3})+\$/", $_POST["secNo"]) === 0) {
         $_SESSION["secBorder"] = "1px solid #aa0000";
         $_SESSION["secWarn"] = true;
         $valid = false;
     }
     if ($valid == false) {
         $this->view("vwNewCard");
     } else {
         $add = $this->model("Cart");
         $add->addCard($_POST["card"], $_POST["expMonth"] . "/" . $_POST["expYear"], $_POST["secNo"], $_SESSION["email"]);
         $this->view($add->view, $add->message);
     }
 }
开发者ID:neerajmorar,项目名称:Switch-Brand,代码行数:32,代码来源:checkout.php

示例10: run

 /**
  * Run method with main page logic
  * 
  * Reads in events for a given month or current month if no parameters are passed.
  * Allow filtering by platform id. Populate template and display event data in a calendar view on the page.
  * @access public
  */
 public function run()
 {
     $PAGINATION_LIMIT = 10;
     $session = Session::getInstance();
     $user = $session->getUser();
     $eventDAO = EventDAO::getInstance();
     $platformDAO = PlatformDAO::getInstance();
     //$page = (isset ($_GET["page"]) && is_numeric ($_GET["page"])) ? intval ($_GET["page"]) : 1;
     $platform_id = isset($_GET["platform"]) && is_numeric($_GET["platform"]) ? intval($_GET["platform"]) : 0;
     $month = isset($_GET["month"]) && is_numeric($_GET["month"]) ? intval($_GET["month"]) : 0;
     $year = isset($_GET["year"]) && is_numeric($_GET["year"]) ? intval($_GET["year"]) : 0;
     //if ($page < 1) {
     //    $page = 1;
     //}
     $count = $paginator = $paginator_page = $event_array = $next_eventday = $prev_eventday = $current_platform = null;
     if ($platform_id > 0 && checkdate($month, 1, $year)) {
         $start = mktime(0, 0, 0, $month, 1, $year);
         $end = strtotime("+1 month", $start) - 1;
         //$count = $eventDAO->countPlatformStatusAndRange ($platform, Event::APPROVED_STATUS, $start, $end);
         //$paginator = new Paginator ($count, 3);
         //$paginator_page = $paginator->getPage ($page);
         $event_array = $eventDAO->allByPlatformStatusAndRange($platform_id, Event::APPROVED_STATUS, $start, $end, array("order" => "{$eventDAO->getTableName()}.date DESC, {$eventDAO->getTableName()}.id DESC", "joins" => true));
     } else {
         if ($platform_id > 0) {
             $start = mktime(0, 0, 0, idate("m"), 1, idate("Y"));
             $end = strtotime("+1 month", $start) - 1;
             //$count = $eventDAO->countPlatformStatusAndRange ($platform, Event::APPROVED_STATUS, $start, $end);
             //$paginator = new Paginator ($count, 3);
             //$paginator_page = $paginator->getPage ($page);
             $event_array = $eventDAO->allByPlatformStatusAndRange($platform_id, Event::APPROVED_STATUS, $start, $end, array("order" => "{$eventDAO->getTableName()}.date DESC, {$eventDAO->getTableName()}.id DESC", "joins" => true));
         } else {
             if (checkdate($month, 1, $year)) {
                 $start = mktime(0, 0, 0, $month, 1, $year);
                 $end = strtotime("+1 month", $start) - 1;
                 //$count = $eventDAO->countStatus (Event::APPROVED_STATUS);
                 //$paginator = new Paginator ($count, 3);
                 //$paginator_page = $paginator->getPage ($page);
                 $event_array = $eventDAO->allByStatusAndRange(Event::APPROVED_STATUS, $start, $end, array("order" => "{$eventDAO->getTableName()}.date DESC, {$eventDAO->getTableName()}.id DESC", "joins" => true));
             } else {
                 $start = mktime(0, 0, 0, idate("m"), 1, idate("Y"));
                 $end = strtotime("+1 month", $start) - 1;
                 //$count = $eventDAO->countStatus (Event::APPROVED_STATUS);
                 //$paginator = new Paginator ($count, 3);
                 //$paginator_page = $paginator->getPage ($page);
                 $event_array = $eventDAO->allByStatusAndRange(Event::APPROVED_STATUS, $start, $end, array("order" => "{$eventDAO->getTableName()}.date DESC, {$eventDAO->getTableName()}.id DESC", "joins" => true));
             }
         }
     }
     $next_eventday = $eventDAO->loadByNextDay($end, Event::APPROVED_STATUS);
     $prev_eventday = $eventDAO->loadByPreviousDay($start, Event::APPROVED_STATUS);
     if ($platform_id > 0) {
         $current_platform = $platformDAO->load($platform_id);
     }
     $platform_array = $platformDAO->all();
     //print_r ($event_array);
     $this->template->render(array("title" => "Event Month Calendar - " . date("F", $start) . " " . date("Y", $start), "main_page" => "events_month_tpl.php", "event_array" => $event_array, "session" => $session, "start" => $start, "end" => $end, "next_eventday" => $next_eventday, "prev_eventday" => $prev_eventday, "sidebar_extra" => joinPath("fragments", "event_sidebar_tpl.php"), "platform_array" => $platform_array, "current_platform" => $current_platform));
 }
开发者ID:Ryochan7,项目名称:UGA-Proposal-Website,代码行数:64,代码来源:events_month.php

示例11: CalculatePaydays

 private function CalculatePaydays($year, PaydayCalc $calc)
 {
     $months = new MonthsCollection();
     $months->Slice(idate("m"));
     while ($months->HasNext()) {
         $this->_paydays->Add(new Payday($calc->GetSalaryDay($year, $months->Current())));
         $this->_paydays->Add(new Payday($calc->GetBonusDay($year, $months->Current())));
         $months->Next();
     }
 }
开发者ID:nbat,项目名称:paydayscalculator,代码行数:10,代码来源:PaydayCalendar.php

示例12: isHourForAlerts

function isHourForAlerts()
{
    date_default_timezone_set('UTC');
    $hour = idate("H");
    if ($hour != 7) {
        return true;
    } else {
        return false;
    }
}
开发者ID:talnitzan82,项目名称:cronAlerts2,代码行数:10,代码来源:mail.php

示例13: __construct

 /**
  * Constructor.
  *
  * @param string $year Year 2014 or * for all (optional)
  *
  * @throws \InvalidArgumentException When year value is invalid
  */
 public function __construct($year = '*')
 {
     if ($year !== '*' && (strlen($year) !== 4 || !ctype_digit($year))) {
         throw new \InvalidArgumentException(sprintf('Year value must be like 2014 or "*", "%s" given.', $year));
     }
     if ($year === '*') {
         $year = idate('Y');
     }
     $this->year = $year;
 }
开发者ID:pokap,项目名称:webarchive,代码行数:17,代码来源:WayBackProvider.php

示例14: GetNextMeeting

 function GetNextMeeting()
 {
     $time = idate("H") * 100 + idate("i");
     // Format time as HHMM (12:34 -> 1234)
     foreach ($this->meetings as $key => $current) {
         if ($current->StartTime > $time) {
             return array($current);
         }
     }
     return array($this->meetings[0]);
 }
开发者ID:yogendra9891,项目名称:basic,代码行数:11,代码来源:server.php

示例15: getSN

 /**
  * 生成SN编号
  * 分为四段 共12位:
  * 第一段 一位 保留字段 默认为0
  * 第二段 三位:生成日期,第一位表示年、第二位表示月、第三位表示日。用字每顺序表示数字,A代表1、B代表2、C代表3,Z代表26以此类推,1代表27、2代表28、3代表29、4代表30、5代表31。
  * 第三段 五位随机数:  从00000-99999 (后续可用来扩展流水号等)
  * 第四段 三位随机数:000-ZZZ
  * 例如:2015年5月13日生成的一条条形码:0PFN93151DQV
  * @return string
  */
 public static function getSN()
 {
     $a = '0';
     $dicArray = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
     $b = $dicArray[intval(idate('y'))] . $dicArray[intval(idate('m'))] . $dicArray[intval(idate('d'))];
     $c = sprintf("%05d", rand(0, 99999));
     $d = '';
     for ($i = 0; $i < 3; $i++) {
         $d .= $dicArray[rand(0, 35)];
     }
     return $a . $b . $c . $d;
 }
开发者ID:hachi-zzq,项目名称:dajiayao,代码行数:22,代码来源:SNMaker.php


注:本文中的idate函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。