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


PHP Time类代码示例

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


在下文中一共展示了Time类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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('evgeniy.siderka@hyuna.bb', '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


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