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


PHP datetime函数代码示例

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


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

示例1: run

 public function run()
 {
     if (!ini_get('safe_mode')) {
         //ooh we can process for sooo long
         set_time_limit(280);
     }
     //get the required classes
     $config =& singleton::get(__NAMESPACE__ . '\\config');
     $plugins =& singleton::get(__NAMESPACE__ . '\\plugins');
     //don't want to stop processing when the http client disconnects
     ignore_user_abort(TRUE);
     //stop from running over and over again
     define('RUNNING_CRON', TRUE);
     //get the cron intervals
     $cron_intervals = $config->get('cron_intervals');
     if (!is_array($cron_intervals)) {
         exit;
     }
     //update intervals first so that slow processing tasks don't hold up the update of the intervals.
     $update_intervals = $cron_intervals;
     $datetime = datetime();
     foreach ($update_intervals as &$update_interval) {
         if ($update_interval['next_run'] < $datetime) {
             $update_interval['next_run'] = datetime($update_interval['frequency']);
         }
     }
     //update cron intervals
     $config->set('cron_intervals', $update_intervals);
     //now to the processing
     foreach ($cron_intervals as $cron_interval) {
         if ($cron_interval['next_run'] < $datetime) {
             $plugins->run('cron_' . $cron_interval['name']);
         }
     }
 }
开发者ID:rnlduadia,项目名称:LAMP-eCommerce-CodeIgniter,代码行数:35,代码来源:cron.class.php

示例2: updateLoginData

 /**
  * 更新用户的最后一次登录ip和时间
  * @access public
  * @param integer $user_id 用户id
  */
 public function updateLoginData($user_id)
 {
     $map['user_id'] = $user_id;
     $map['last_login_ip'] = get_client_ip();
     $map['last_login_time'] = datetime();
     $this->save($map);
 }
开发者ID:scaukk,项目名称:Moment,代码行数:12,代码来源:UserModel.class.php

示例3: add

 function add($array)
 {
     global $db;
     if (!isset($array['start_date'])) {
         $array['start_date'] = '0000-00-00 00:00:00';
     }
     $tables =& singleton::get(__NAMESPACE__ . '\\tables');
     $error =& singleton::get(__NAMESPACE__ . '\\error');
     //we require an array
     if (!is_array($array['data'])) {
         return false;
     }
     reset($array['data']);
     $queue_data = \base64_encode(\serialize($array['data']));
     $queue_date = datetime();
     $site_id = SITE_ID;
     $query = "INSERT INTO {$tables->queue} (data, type, start_date, date, site_id) VALUES (:data, :type, :start_date, :date, :site_id)";
     try {
         $stmt = $db->prepare($query);
     } catch (\Exception $e) {
         $error->create(array('type' => 'sql_prepare_error', 'message' => $e->getMessage()));
     }
     $stmt->bindParam(':data', $queue_data, database::PARAM_STR);
     $stmt->bindParam(':type', $array['type'], database::PARAM_STR);
     $stmt->bindParam(':start_date', $array['start_date'], database::PARAM_STR);
     $stmt->bindParam(':date', $queue_date, database::PARAM_STR);
     $stmt->bindParam(':site_id', $site_id, database::PARAM_STR);
     try {
         $stmt->execute();
     } catch (\Exception $e) {
         $error->create(array('type' => 'sql_execute_error', 'message' => $e->getMessage()));
     }
     return true;
 }
开发者ID:rnlduadia,项目名称:LAMP-eCommerce-CodeIgniter,代码行数:34,代码来源:queue.class.php

示例4: getDeadline

 public function getDeadline($deadline)
 {
     if ('now' == I('request.create_time_choose')) {
         return datetime('now');
     } else {
         return datetime($deadline);
     }
 }
开发者ID:GeoffreyQiao,项目名称:SublimePHPNinJaManual,代码行数:8,代码来源:PostModel.class.php

示例5: like

 /**
  * Function: like
  * Adds a like to the database.
  */
 public function like()
 {
     if ($this->action == "like" and $this->post_id > 0) {
         SQL::current()->insert("likes", array("post_id" => $this->post_id, "user_id" => $this->user_id, "timestamp" => datetime(), "session_hash" => $this->session_hash));
     } else {
         throw new Exception("invalid params- action = {$this->action} and post_id = {$this->post_id}");
     }
 }
开发者ID:betsyzhang,项目名称:chyrp,代码行数:12,代码来源:model.Like.php

示例6: main_index

 public function main_index($main)
 {
     $config = Config::current();
     if ($config->disable_aggregation or time() - $config->last_aggregation < $config->aggregate_every * 60) {
         return;
     }
     $aggregates = (array) $config->aggregates;
     if (empty($aggregates)) {
         return;
     }
     foreach ($aggregates as $name => $feed) {
         $xml_contents = preg_replace(array("/<(\\/?)dc:date>/", "/xmlns=/"), array("<\\1date>", "a="), get_remote($feed["url"]));
         $xml = simplexml_load_string($xml_contents, "SimpleXMLElement", LIBXML_NOCDATA);
         if ($xml === false) {
             continue;
         }
         # Flatten namespaces recursively
         $this->flatten($xml);
         $items = array();
         if (isset($xml->entry)) {
             foreach ($xml->entry as $entry) {
                 array_unshift($items, $entry);
             }
         } elseif (isset($xml->item)) {
             foreach ($xml->item as $item) {
                 array_unshift($items, $item);
             }
         } else {
             foreach ($xml->channel->item as $item) {
                 array_unshift($items, $item);
             }
         }
         foreach ($items as $item) {
             $date = oneof(@$item->pubDate, @$item->date, @$item->updated, 0);
             $updated = strtotime($date);
             if ($updated > $feed["last_updated"]) {
                 # Get creation date ('created' in Atom)
                 $created = @$item->created ? strtotime($item->created) : 0;
                 if ($created <= 0) {
                     $created = $updated;
                 }
                 # Construct the post data from the user-defined XPath mapping:
                 $data = array("aggregate" => $name);
                 foreach ($feed["data"] as $attr => $field) {
                     $field = !empty($field) ? $this->parse_field($field, $item) : "";
                     $data[$attr] = is_string($field) ? $field : YAML::dump($field);
                 }
                 if (isset($data["title"]) or isset($data["name"])) {
                     $clean = sanitize(oneof(@$data["title"], @$data["name"]));
                 }
                 Post::add($data, $clean, null, $feed["feather"], $feed["author"], false, "public", datetime($created), datetime($updated));
                 $aggregates[$name]["last_updated"] = $updated;
             }
         }
     }
     $config->set("aggregates", $aggregates);
     $config->set("last_aggregation", time());
 }
开发者ID:eadz,项目名称:chyrp,代码行数:58,代码来源:aggregator.php

示例7: mail_digest

 static function mail_digest($to, $subject, $message, $headers)
 {
     $output = "\r\n" . $headers . "\r\n" . "To: " . $to . "\r\n" . "Date: " . datetime() . "\r\n" . "Subject: " . $subject . "\r\n\r\n" . $message . "\r\n\r\n" . "---correspondence---\r\n";
     if (@file_put_contents(MAIN_DIR . DIR . "digest.txt.php", $output, FILE_APPEND)) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:xenocrat,项目名称:chyrp-mail_to_file,代码行数:9,代码来源:mail_to_file.php

示例8: add

 public function add($array)
 {
     global $db;
     $tables =& singleton::get(__NAMESPACE__ . '\\tables');
     $error =& singleton::get(__NAMESPACE__ . '\\error');
     $notifications =& singleton::get(__NAMESPACE__ . '\\notifications');
     $messages =& singleton::get(__NAMESPACE__ . '\\messages');
     $site_id = SITE_ID;
     $date_added = datetime();
     $query = "INSERT INTO {$tables->message_notes} (user_id, site_id, date_added";
     if (isset($array['message_id'])) {
         $query .= ", message_id";
     }
     if (isset($array['message'])) {
         $query .= ", message";
     }
     $query .= ") VALUES (:user_id, :site_id, :date_added";
     if (isset($array['message_id'])) {
         $query .= ", :message_id";
     }
     if (isset($array['message'])) {
         $query .= ", :message";
     }
     $query .= ")";
     try {
         $stmt = $db->prepare($query);
     } catch (\Exception $e) {
         $error->create(array('type' => 'sql_prepare_error', 'message' => $e->getMessage()));
     }
     $stmt->bindParam(':user_id', $array['user_id'], database::PARAM_INT);
     $stmt->bindParam(':site_id', $site_id, database::PARAM_INT);
     $stmt->bindParam(':date_added', $date_added, database::PARAM_STR);
     if (isset($array['message_id'])) {
         $stmt->bindParam(':message_id', $array['message_id'], database::PARAM_INT);
     }
     if (isset($array['message'])) {
         $stmt->bindParam(':message', $array['message'], database::PARAM_STR);
     }
     try {
         $stmt->execute();
         $id = $db->lastInsertId();
         if (isset($array['message_id'])) {
             $messages->edit(array('id' => $array['message_id']));
         }
         $notifications->new_message_note(array('user_id' => $array['user_id']));
         return $id;
     } catch (\PDOException $e) {
         $error->create(array('type' => 'sql_execute_error', 'message' => $e->getMessage()));
     }
 }
开发者ID:rnlduadia,项目名称:LAMP-eCommerce-CodeIgniter,代码行数:50,代码来源:message_notes.class.php

示例9: __construct

 public function __construct($user = null)
 {
     $this->_db = DB::getInstance();
     $this->_sessionName = Config::get('session/session_name');
     $this->_cookieName = Config::get('remember/cookie_name');
     if (!$user) {
         if (Session::exists($this->_sessionName)) {
             $user = Session::get($this->_sessionName);
             if ($this->find($user)) {
                 $this->_isLoggedIn = true;
                 $this->update(array('LastLogin' => datetime()));
             }
         }
     } else {
         $this->find($user);
     }
 }
开发者ID:Jaironlanda,项目名称:Hostel-Management-System,代码行数:17,代码来源:User.php

示例10: update

 public function update($filename = null, $path = null, $entity_type = null, $entity_id = null)
 {
     if ($this->no_results) {
         return false;
     }
     $sql = SQL::current();
     $trigger = Trigger::current();
     $old = clone $this;
     foreach (array("filename", "path", "entity_type", "entity_id") as $attr) {
         if ($attr == "updated_at" and $updated_at === null) {
             $this->updated_at = $updated_at = datetime();
         } else {
             $this->{$attr} = ${$attr} = ${$attr} === null ? $this->{$attr} : ${$attr};
         }
     }
     $sql->update("attachments", array("id" => $this->id), array("filename" => $filename, "path" => $path, "entity_type" => $entity_type, "entity_id" => $entity_id));
     $trigger->call("update_attachment", $this, $old);
 }
开发者ID:vito,项目名称:chyrp-site,代码行数:18,代码来源:model.Attachment.php

示例11: edit

 public function edit($array)
 {
     global $db;
     $tables =& singleton::get(__NAMESPACE__ . '\\tables');
     $error =& singleton::get(__NAMESPACE__ . '\\error');
     $site_id = SITE_ID;
     $last_modified = datetime();
     $query = "UPDATE {$tables->messages} SET site_id = :site_id";
     if (isset($array['from_user_id'])) {
         $query .= ", from_user_id = :from_user_id";
     }
     if (isset($array['subject'])) {
         $query .= ", subject = :subject";
     }
     if (isset($array['message'])) {
         $query .= ", message = :message";
     }
     $query .= ", last_modified = :last_modified";
     $query .= " WHERE id = :id AND site_id = :site_id";
     try {
         $stmt = $db->prepare($query);
     } catch (\PDOException $e) {
         $error->create(array('type' => 'sql_prepare_error', 'message' => $e->getMessage()));
     }
     $stmt->bindParam(':id', $array['id'], database::PARAM_INT);
     $stmt->bindParam(':site_id', $site_id, database::PARAM_INT);
     if (isset($array['from_user_id'])) {
         $stmt->bindParam(':from_user_id', $array['from_user_id'], database::PARAM_INT);
     }
     if (isset($array['subject'])) {
         $stmt->bindParam(':subject', $array['subject'], database::PARAM_STR);
     }
     if (isset($array['message'])) {
         $stmt->bindParam(':message', $array['message'], database::PARAM_STR);
     }
     $stmt->bindParam(':last_modified', $last_modified, database::PARAM_STR);
     try {
         $stmt->execute();
     } catch (\PDOException $e) {
         $error->create(array('type' => 'sql_execute_error', 'message' => $e->getMessage()));
     }
 }
开发者ID:rnlduadia,项目名称:LAMP-eCommerce-CodeIgniter,代码行数:42,代码来源:messages.class.php

示例12: datetime

	<div class='empty'>
	</div>
	
	<div id='content'>
		<h1 id='header'>Καλώς Ήρθατε στο <strong>|= Ω 2 \_/ ^^</strong> μας!</h1>
		<?php 
if (isset($_COOKIE['userid'])) {
    ?>
<p>Welcome, <?php 
    echo $_COOKIE['username'];
    ?>
 <a href="http://127.0.0.1/forum/logout.php" id="exit">Αποσύνδεση</a></p><?php 
    include '/../models/users.php';
    include '/../models/database.php';
    include '/../models/datetime.php';
    $now = datetime();
    LastActive($_COOKIE['userid'], $now);
} else {
    ?>
<p> Welcome, Guest. Please <a href="http://127.0.0.1/forum/login.php"> Login</a> or  <a href="http://127.0.0.1/forum/register.php" />Register</p><?php 
}
?>
	</div>
	
	<div class='empty'>
	</div>
	
	<div id='navbar'>
		<a href="recenttopics.php">View Recent Topics</a>
		<a href="index.php" >Index Board</a>
	</div>
开发者ID:panayiotisd,项目名称:forum,代码行数:31,代码来源:header.php

示例13: str_replace

             $display_name_fix = $result['Name'];
             // Insert Name
             $output = str_replace('nameString2', $display_name_fix, $html);
             // Insert Function
             $output = str_replace('functionString', $display_function, $output);
             $output = str_replace('userName', $display_name_str, $output);
             // Insert URL
             $output = str_replace('urlString', $display_url, $output);
             // All
             $output = str_replace('lvlvlv', $lvlvlv, $output);
             $output = str_replace('nextlevel', $nextlevel, $output);
             $output = str_replace('nexttimelv', $nexttimelv, $output);
             if ($result['pDataReg'] != null) {
                 $output = str_replace('datareg', datetime($result['pDataReg']), $output);
             } else {
                 $output = str_replace('datareg', datetime('1/1/2000'), $output);
             }
             $output = str_replace('ponline', $ponline, $output);
             // Output
             //$tpl->set( '{search_name}', implode( "\n", $while ) );
             $tpl_output[] = $output;
         }
     }
 } else {
     $output = str_replace('urlString', 'javascript:void(0);', $html2);
     $output = str_replace('nameString', 'На сервере нет такого пользователя.', $output);
     $output = str_replace('functionString', '0', $output);
     // Format No Results Output
     /*
     $output = str_replace('urlString', 'javascript:void(0);', $html);
     $output = str_replace('nameString', '<b>No Results Found.</b>', $output);
开发者ID:nekleenov,项目名称:sampucp,代码行数:31,代码来源:search.php

示例14: update

 /**
  * Function: update
  * Updates a post with the given attributes.
  *
  * Most of the function arguments will fall back to various POST values.
  *
  * Parameters:
  *     $values - An array of data to set for the post.
  *     $user - <User> to set as the post's author.
  *     $pinned - Pin the post?
  *     $status - Post status
  *     $clean - A new clean URL for the post.
  *     $url - A new URL for the post.
  *     $created_at - New @created_at@ timestamp for the post.
  *     $updated_at - New @updated_at@ timestamp for the post, or @false@ to not updated it.
  *     $options - Options for the post.
  *
  * See Also:
  *     <add>
  */
 public function update($values = null, $user = null, $pinned = null, $status = null, $clean = null, $url = null, $created_at = null, $updated_at = null, $options = null)
 {
     if ($this->no_results) {
         return false;
     }
     $trigger = Trigger::current();
     $user_id = $user instanceof User ? $user->id : $user;
     fallback($values, array_combine($this->attribute_names, $this->attribute_values));
     fallback($user_id, oneof(@$_POST['user_id'], $this->user_id));
     fallback($pinned, (int) (!empty($_POST['pinned'])));
     fallback($status, isset($_POST['draft']) ? "draft" : oneof(@$_POST['status'], $this->status));
     fallback($clean, $this->clean);
     fallback($url, oneof(@$_POST['slug'], $this->feather . "." . $this->id));
     fallback($created_at, !empty($_POST['created_at']) ? datetime($_POST['created_at']) : $this->created_at);
     fallback($updated_at, $updated_at === false ? $this->updated_at : oneof($updated_at, @$_POST['updated_at'], datetime()));
     fallback($options, oneof(@$_POST['option'], array()));
     if ($url != $this->url) {
         # If they edited the slug, the clean URL should change too.
         $clean = $url;
     }
     $old = clone $this;
     # Update all values of this post.
     foreach (array("user_id", "pinned", "status", "url", "created_at", "updated_at") as $attr) {
         $this->{$attr} = ${$attr};
     }
     $new_values = array("pinned" => $pinned, "status" => $status, "clean" => $clean, "url" => $url, "created_at" => $created_at, "updated_at" => $updated_at);
     $trigger->filter($new_values, "before_update_post");
     $sql = SQL::current();
     $sql->update("posts", array("id" => $this->id), $new_values);
     # Insert the post attributes.
     foreach (array_merge($values, $options) as $name => $value) {
         if ($sql->count("post_attributes", array("post_id" => $this->id, "name" => $name))) {
             $sql->update("post_attributes", array("post_id" => $this->id, "name" => $name), array("value" => $this->{$name} = $value));
         } else {
             $sql->insert("post_attributes", array("post_id" => $this->id, "name" => $name, "value" => $this->{$name} = $value));
         }
     }
     $trigger->call("update_post", $this, $old, $options);
 }
开发者ID:relisher,项目名称:chyrp,代码行数:59,代码来源:Post.php

示例15: array

            $sql->replace("permissions", array("id", "group_id"), array("id" => $id, "name" => $name, "group_id" => 0));
        }
        $groups = array("admin" => array_keys($names), "member" => array("view_site"), "friend" => array("view_site", "view_private", "view_scheduled"), "banned" => array(), "guest" => array("view_site"));
        # Insert the default groups (see above)
        $group_id = array();
        foreach ($groups as $name => $permissions) {
            $sql->replace("groups", "name", array("name" => ucfirst($name)));
            $group_id[$name] = $sql->latest("groups");
            foreach ($permissions as $permission) {
                $sql->replace("permissions", array("id", "group_id"), array("id" => $permission, "name" => $names[$permission], "group_id" => $group_id[$name]));
            }
        }
        $config->set("default_group", $group_id["member"]);
        $config->set("guest_group", $group_id["guest"]);
        if (!$sql->select("users", "id", array("login" => $_POST['login']))->fetchColumn()) {
            $sql->insert("users", array("login" => $_POST['login'], "password" => User::hashPassword($_POST['password_1']), "email" => $_POST['email'], "website" => $config->url, "group_id" => $group_id["admin"], "approved" => true, "joined_at" => datetime()));
        }
        $installed = true;
    }
}
function value_fallback($index, $fallback = "")
{
    echo isset($_POST[$index]) ? fix($_POST[$index]) : $fallback;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
        <title>Chyrp Installer</title>
开发者ID:betsyzhang,项目名称:chyrp,代码行数:31,代码来源:install.php


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