• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Time类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testCompile

 public function testCompile()
 {
     $field = new Time("test", "Test");
     $expected = "<label for=\"test\">Test</label><input type=\"time\" name=\"test\"  value=\"\" />";
     $value = $field->compile();
     $this->assertEquals($expected, $value);
 }
开发者ID:jenwachter,项目名称:html-form,代码行数:7,代码来源:TimeTest.php


示例2: testTimeDeleteMethodWithInvalidData

 /**
  * Tests delete time method that it raises and error if invalid data is passed in
  * @group time
  * @dataProvider getInvalidData
  * @expectedException PHPUnit_Framework_Error
  * @param $data
  */
 public function testTimeDeleteMethodWithInvalidData($data)
 {
     $entity = new Time();
     $date = $data['time_delete'];
     $entity->setTimeDelete($date);
     $this->assertEquals($date, $entity->getTimeDelete());
 }
开发者ID:tomazahlin,项目名称:symfony-core-bundle,代码行数:14,代码来源:TimestampableTraitTest.php


示例3: fromFormat

 /**
  * @param string $format
  * @param string $value
  * @return \WallaceMaxters\Timer\Time
  */
 public function fromFormat($format, $value)
 {
     $matches = $this->getMatches($format, $value);
     $time = new Time($matches['h'], $matches['i'], $matches['s']);
     if ($this->isNegativeSign($matches['r'])) {
         $time->multiply(-1);
     }
     return $time;
 }
开发者ID:wallacemaxters,项目名称:timer,代码行数:14,代码来源:Parser.php


示例4: currentMicro

 public function currentMicro()
 {
     // if no time was set, we return the fallback value
     if ($this->nextCurrentMicro < 0.0) {
         return $this->realTime->currentMicro();
     }
     // return the previously set value and reset the internal var
     $current = $this->nextCurrentMicro;
     $this->nextCurrentMicro = -1.0;
     return $current;
 }
开发者ID:plista,项目名称:core,代码行数:11,代码来源:MockTime.php


示例5: start

 static function start()
 {
     if (!Lock::isOn('cron-running-' . $_ENV['projectName'])) {
         if (Lock::on('cron-running-' . $_ENV['projectName'])) {
             Debug::out('Starting');
             Control::req('scripts/crons/config');
             while (!Lock::isOn('cron-off-' . $_ENV['projectName'])) {
                 $time = new Time();
                 //+	ensure running only every minute {
                 $parseTime = $time->format('YmdHi');
                 if (self::$lastParsedTime == $parseTime) {
                     sleep(2);
                     continue;
                 }
                 self::$lastParsedTime = $parseTime;
                 //+	}
                 //+	execute run items {
                 $run = self::getRun($time);
                 foreach ($run as $i) {
                     $item = self::$list[$i];
                     if (self::$running[$i]) {
                         $pid = pcntl_waitpid(self::$running[$i], $status, WNOHANG);
                         if ($pid == 0) {
                             //process is currently running, don't run again
                             continue;
                         } elseif ($pid == -1) {
                             Debug::out('Process error:', $item);
                             continue;
                         }
                     }
                     $pid = pcntl_fork();
                     if ($pid == -1) {
                         Debug::quit('Could not fork process', $item);
                     } elseif ($pid) {
                         //this is the parent
                         self::$running[$i] = $pid;
                     } else {
                         //this is the child
                         self::$args = $item[2];
                         $script = Config::userFileLocation($item[1], 'control/scripts/crons');
                         Control::req($script);
                         exit;
                     }
                 }
                 //+	}
             }
             Lock::off('cron-running-' . $_ENV['projectName']);
         } else {
             Debug::quit('Failed to lock "cron-running"');
         }
     } else {
         Debug::quit('Cron already running');
     }
 }
开发者ID:jstacoder,项目名称:brushfire,代码行数:54,代码来源:Cron.php


示例6: api_load_times

 public function api_load_times()
 {
     /*Initialize the Mite API connector class*/
     $mite = new Mite\Mite(MITE_SUB, MITE_KEY);
     /*Get your own userID*/
     $userID = $mite->getMyself()->id;
     $stepper = array('a' => 0, 'u' => 0);
     /*Get all times which belong to me*/
     $e = $mite->getTimes(array(), array(), array(), array($userID), null, false, false, false, false, null, MITE_TIMES, false);
     for ($e->rewind(); $e->valid(); $e->next()) {
         $entry = $e->current();
         /*MAP ALL TIMES WITH WORKTIME*/
         if ($entry->minutes > 0) {
             $time = Time::find(array('conditions' => array('project_name = ? AND service_name = ? AND minutes = ? AND created = ?', $entry->project_name, $entry->service_name, $entry->minutes, strtotime($entry->date_at))));
             if (!$time) {
                 $save = Time::create(array('project_name' => $entry->project_name, 'service_name' => $entry->service_name, 'minutes' => $entry->minutes, 'created' => strtotime($entry->date_at)));
                 $stepper['a']++;
             } else {
                 $time->project_name = $entry->project_name;
                 $time->service_name = $entry->service_name;
                 $time->minutes = $entry->minutes;
                 $time->created = strtotime($entry->date_at);
                 $time->save();
                 $stepper['u']++;
             }
         }
         unset($entry);
     }
     /*Status*/
     echo "\t\t\t" . $stepper['a'] . " entries " . ($stepper['a'] > 1 ? 'have' : 'has') . " been added...\n";
     echo "\t\t\t" . $stepper['u'] . " entries " . ($stepper['u'] > 1 ? 'have' : 'has') . " been updated...\n";
 }
开发者ID:Webklex,项目名称:addl,代码行数:32,代码来源:userController.php


示例7: sqlTime

 public static function sqlTime($timestamp = null)
 {
     if ($timestamp !== null && !is_numeric($timestamp)) {
         $timestamp = Time::time($timestamp);
     }
     return $timestamp ? date('H:i:s', $timestamp) : date('H:i:s');
 }
开发者ID:dubhunter,项目名称:talon,代码行数:7,代码来源:Date.php


示例8: getContext

	/**
	 *	@interface ContextService
	**/
	public function getContext($model){
		$conn = $model['conn'];
		$stgname = $conn->escape($model['stgname']);
		$filename = $conn->escape($model['filename']);
		$mime = $conn->escape($model['mime']);
		$owner = $model['owner'];
		$access = $model['access'];
		$group = $model['group'];
		$dirid = $conn->escape($model['dirid']);
		
		$stgid = Random::getString(128); 
		$ts = Time::getTime();
		
		$query = "insert into storages (stgid, stgname, filename, mime, owner, access, group, ctime, atime, mtime, dirid) values ('$stgid', '$stgname', '$filename', '$mime', $owner, $access, $group, $ts, $ts, $ts, '$dirid')";
		$result = $conn->getResult($query);
		
		if($result === false){
			$model['valid'] = false;
			$model['msg'] = 'Error in Database @getContext/storage.create';
			return $model;
		}
		
		$model['valid'] = true;
		$model['stgid'] = $stgid;
		return $model;
	}
开发者ID:nimitz92,项目名称:enhanCSE-core,代码行数:29,代码来源:StorageCreateContext.class.php


示例9: actionIndex

 public function actionIndex($isForced = false, $isDebug = false)
 {
     $console = Console::getInstance($isForced, $isDebug);
     $console->debugStart('Entered');
     //        if (mail('[email protected]', 'test', 'test message')) {
     //            $console->writeLine('OK');
     //        } else {
     //            $console->writeLine('Failure');
     //        }
     $newExecutors = Site::getNewExecutors('2015-11-19 12:20:00');
     $report = '';
     foreach ($newExecutors as $e) {
         $sites = Site::model()->findAllByAttributes(array('executor_id' => $e));
         if (count($sites) < 1) {
             continue;
         }
         $report .= String::build('Positions for "{keyword}" ({date_from} - {date_to})', array('keyword' => $sites[0]->keyword->name, 'date_from' => Time::toPretty($sites[0]->updated_at), 'date_to' => Time::toPretty($sites[count($sites) - 1]->updated_at))) . PHP_EOL;
         foreach ($sites as $s) {
             $report .= String::build('{position}: {site}', array('position' => $s->position, 'site' => String::rebuildUrl($s->link, false, false, true, false))) . PHP_EOL;
         }
     }
     $console->writeLine($report);
     $console->debugEnd();
     return;
 }
开发者ID:evgeniys-hyuna,项目名称:leadsite,代码行数:25,代码来源:TestCommand.php


示例10: testRenderModified

 public function testRenderModified()
 {
     $time = Time::create(Time::PUBLISHED)->withDatetime($this->timeDate);
     $expected = '<time class="op-published" datetime="1984-08-14T19:30:00+00:00">' . 'August 14th, 7:30pm' . '</time>';
     $rendered = $time->render();
     $this->assertEquals($expected, $rendered);
 }
开发者ID:ActiveWebsite,项目名称:BoojPressPlugins,代码行数:7,代码来源:TimeTest.php


示例11: set

 /**
  *	@fn set
  *	@short Action method to set the user's home language.
  */
 public function set()
 {
     $lang = isset($_REQUEST['id']) ? $_REQUEST['id'] : 'en';
     Cookie::set('hl', $lang, Time::next_year(), '/');
     $this->redirect_to_referrer();
     $this->redirect_to(array('controller' => 'home'));
 }
开发者ID:emeraldion,项目名称:zelda,代码行数:11,代码来源:language_controller.php


示例12: p_signup

 public function p_signup()
 {
     # What data was submitted
     //print_r($_POST);
     # Encrypt password
     $_POST['password'] = sha1(PASSWORD_SALT . $_POST['password']);
     $_POST['password2'] = sha1(PASSWORD_SALT . $_POST['password2']);
     if ($_POST['password'] != $_POST['password2']) {
         Router::redirect('/users/login/new/?error=oh+dip!+password+mismatch,+please+try+again.');
     }
     # delete confirmation password from post for nice easy insert into db
     unset($_POST['password2']);
     # Create and encrypt token
     $_POST['token'] = sha1(TOKEN_SALT . $_POST['username'] . Utils::generate_random_string());
     # Store current timestamp
     $_POST['created'] = Time::now();
     # This returns the current timestamp
     $_POST['modified'] = Time::now();
     # Insert
     DB::instance(DB_NAME)->insert('users', $_POST);
     # set token / cookie so user doesn't have to log in again
     $token = $_POST['token'];
     setcookie("token", $token, strtotime('+2 weeks'), '/');
     Router::redirect('/');
 }
开发者ID:nbotchan,项目名称:dwa,代码行数:25,代码来源:c_users.php


示例13: HookRenderPage

 /**
  * Hook on the page render, use this to look for generic metadata and map those over to opengraph data.
  *
  * @param View $view
  */
 public static function HookRenderPage(View $view)
 {
     if (!isset($view->meta['og:type'])) {
         $view->meta['og:type'] = 'website';
     }
     if (!isset($view->meta['og:title'])) {
         $view->meta['og:title'] = $view->title;
     }
     if ($view->canonicalurl) {
         $view->meta['og:url'] = $view->canonicalurl;
     }
     if (isset($view->meta['description'])) {
         $view->meta['og:description'] = str_replace(array("\r\n", "\r", "\n"), ' ', $view->meta['description']);
     }
     // Articles can have some specific information.
     if ($view->meta['og:type'] == 'article') {
         $view->meta['og:article:modified_time'] = Time::FormatGMT($view->updated, Time::TIMEZONE_GMT, 'r');
         if (isset($view->meta['author'])) {
             $view->meta['og:article:author'] = $view->meta['author'];
         }
     }
     if (FACEBOOK_APP_ID) {
         $view->meta['fb:app_id'] = FACEBOOK_APP_ID;
     }
     /*
      * other article tags:
     article:published_time - datetime - When the article was first published.
     article:modified_time - datetime - When the article was last changed.
     article:expiration_time - datetime - When the article is out of date after.
     article:author - profile array - Writers of the article.
     article:section - string - A high-level section name. E.g. Technology
     article:tag - string array - Tag words associated with this article.
     */
 }
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:39,代码来源:FacebookHelper.class.php


示例14: getContext

	/**
	 *	@interface ContextService
	**/
	public function getContext($model){
		$conn = $model['conn'];
		$uid = $model['uid'];
		$interval = $model['interval'];

		$sessionid = Random::getString(32); 
		$ts = Time::getTime();
		$ts_exp = $ts + $interval;
		
		$query = "delete from sessions where expiry < $ts;";
		$conn->getResult($query, true);
		
		$query = "insert into sessions values('$sessionid', $uid, $ts, $ts_exp);";
		$result = $conn->getResult($query, true);
		
		if($result === false){
			$model['valid'] = false;
			$model['msg'] = 'Error in Database @getContext/session.create';
			return $model;
		}
		
		$model['valid'] = true;
		$model['sessionid'] = $sessionid;

		return $model;
	}
开发者ID:nimitz92,项目名称:enhanCSE-core,代码行数:29,代码来源:SessionCreateContext.class.php


示例15: testStartWithArray

 public function testStartWithArray()
 {
     $driver = $this->buildMock();
     $driver->expects($this->once())->method('measureTime')->with('foo/bar');
     Drivers::set($driver);
     Time::start(["foo", "bar"]);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:7,代码来源:TimeTest.php


示例16: p_signup

 public function p_signup()
 {
     # Check if data was entered
     if ($_POST['first_name'] == "" || $_POST['last_name'] == "" || $_POST['password'] == "") {
         # Send back to signup with appropriate error
         Router::redirect("/users/signup/Please enter all requested information");
     }
     # Check if email address is of the right form
     if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
         # Send back to signup with appropriate error
         Router::redirect("/users/signup/Please enter a valid email address");
     }
     # Check if passwords match
     if ($_POST['password'] != $_POST['password_check']) {
         # Send back to signup with appropriate error
         Router::redirect("/users/signup/Passwords do not match");
     }
     # Remove the password check from the array
     unset($_POST['password_check']);
     # Encrypt the password
     $_POST['password'] = sha1(PASSWORD_SALT . $_POST['password']);
     # More data we want stored with the user
     $_POST['created'] = Time::now();
     $_POST['modified'] = Time::now();
     $_POST['token'] = sha1(TOKEN_SALT . $_POST['email'] . Utils::generate_random_string());
     # Insert this user into the database
     $user_id = DB::instance(DB_NAME)->insert("users", $_POST);
     # Send the user to the signup success page
     $this->template->content = View::instance('v_users_signup_success');
     $this->template->title = "Success!";
     echo $this->template;
 }
开发者ID:nvarney,项目名称:dwa_prod,代码行数:32,代码来源:c_users.php


示例17: set

 public function set($k, $v)
 {
     switch ($k) {
         case 'status':
             // Update the published date if it's status has changed.
             if ($v == $this->get($k)) {
                 return false;
             }
             if ($v == 'published' && !$this->get('published')) {
                 parent::set('published', Time::GetCurrentGMT());
             } elseif ($v == 'draft' && $this->get('published')) {
                 parent::set('published', '');
             }
             // And resume!
             return parent::set($k, $v);
         case 'published':
             // make sure this is a valid timestamp!
             if ($v != '' && !is_numeric($v)) {
                 $time = strtotime($v);
                 return parent::set($k, $time);
             } else {
                 return parent::set($k, $v);
             }
         default:
             return parent::set($k, $v);
     }
 }
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:27,代码来源:BlogArticleModel.php


示例18: testIsRTLEnabled

 public function testIsRTLEnabled()
 {
     $article = InstantArticle::create()->withCanonicalURL('http://wp.localtest.me/2016/04/12/stress-on-earth/')->enableAutomaticAdPlacement()->enableRTL()->withHeader(Header::create()->withTitle(H1::create()->appendText('Peace on <b>earth</b>'))->addAuthor(Author::create()->withName('bill'))->withPublishTime(Time::create(Time::PUBLISHED)->withDatetime(\DateTime::createFromFormat('j-M-Y G:i:s', '14-Aug-1984 19:30:00'))))->addChild(Paragraph::create()->appendText('Yes, peace is good for everybody!')->appendText(LineBreak::create())->appendText(' Man kind.'));
     $result = $article->render();
     $expected = '<!doctype html>' . '<html dir="rtl">' . '<head>' . '<link rel="canonical" href="http://wp.localtest.me/2016/04/12/stress-on-earth/"/>' . '<meta charset="utf-8"/>' . '<meta property="op:generator" content="facebook-instant-articles-sdk-php"/>' . '<meta property="op:generator:version" content="1.5.2"/>' . '<meta property="op:markup_version" content="v1.0"/>' . '</head>' . '<body>' . '<article>' . '<header>' . '<h1>Peace on &lt;b&gt;earth&lt;/b&gt;</h1>' . '<time class="op-published" datetime="1984-08-14T19:30:00+00:00">August 14th, 7:30pm</time>' . '<address>' . '<a>bill</a>' . '</address>' . '</header>' . '<p>Yes, peace is good for everybody!<br/> Man kind.</p>' . '</article>' . '</body>' . '</html>';
     $this->assertEquals($expected, $result);
 }
开发者ID:facebook,项目名称:facebook-instant-articles-sdk-php,代码行数:7,代码来源:InstantArticleTest.php


示例19: print_date_span

/**
* Print out week being viewed above schedule tables
* @param array $d array of date information about this schedule
* @param string $title title of schedule
*/
function print_date_span($d, $title)
{
    // Print out current week being viewed
    // echo '<h3 align="center">' . $title . '<br/>' . Time::formatDate($d['firstDayTs']) . ' - ' . Time::formatDate($d['lastDayTs']) . '</h3>';
    // AK: Updated version. We want to display current date only.
    echo '<h3 align="center">' . Time::formatDate($d['todayTs']) . '</h3>';
}
开发者ID:razagilani,项目名称:srrs,代码行数:12,代码来源:schedule.template.php


示例20: getContext

	/**
	 *	@interface ContextService
	**/
	public function getContext($model){
		$conn = $model['conn'];
		$stgid = $conn->escape($model['stgid']);
		$uid = $model['uid'];
		$access = $model['access'];
		
		$ts = Time::getTime();
		
		$query = "update storages set access=$access, mtime=$ts where stgid='$stgid' and owner=$uid))";
		$result = $conn->getResult($query);
		
		if($result === false){
			$model['valid'] = false;
			$model['msg'] = 'Error in Database @getContext/storage.chmod';
			return $model;
		}
		
		if($result != 1){
			$model['valid'] = false;
			$model['msg'] = 'Invalid Storage ID / Not Permitted';
			return $model;
		}
		
		$model['valid'] = true;
		return $model;
	}
开发者ID:nimitz92,项目名称:enhanCSE-core,代码行数:29,代码来源:StorageChmodContext.class.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP TimeDate类代码示例发布时间:2022-05-23
下一篇:
PHP TimberURLHelper类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap