本文整理汇总了PHP中Time::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Time::create方法的具体用法?PHP Time::create怎么用?PHP Time::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Time
的用法示例。
在下文中一共展示了Time::create方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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";
}
示例2: 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 <b>earth</b></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);
}
示例3: 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);
}
示例4: testCompleteHeader
public function testCompleteHeader()
{
date_default_timezone_set('UTC');
$inline = '<script>alert("test & more test");</script>';
$header = Header::create()->withTitle('Big Top Title')->withSubTitle('Smaller SubTitle')->withPublishTime(Time::create(Time::PUBLISHED)->withDatetime(\DateTime::createFromFormat('j-M-Y G:i:s', '14-Aug-1984 19:30:00')))->withModifyTime(Time::create(Time::MODIFIED)->withDatetime(\DateTime::createFromFormat('j-M-Y G:i:s', '10-Feb-2016 10:00:00')))->addAuthor(Author::create()->withName('Author One')->withDescription('Passionate coder and mountain biker'))->addAuthor(Author::create()->withName('Author Two')->withDescription('Weend surfer with heavy weight coding skils')->withURL('http://facebook.com/author'))->withKicker('Some kicker of this article')->withCover(Image::create()->withURL('https://jpeg.org/images/jpegls-home.jpg')->withCaption(Caption::create()->appendText('Some caption to the image')))->addAd(Ad::create()->withSource('http://foo.com'))->addAd(Ad::create()->withSource('http://foo.com')->withWidth(350)->withHeight(50)->enableDefaultForReuse())->addAd(Ad::create()->withWidth(300)->withHeight(250)->enableDefaultForReuse()->withHTML($inline));
$expected = '<header>' . '<figure>' . '<img src="https://jpeg.org/images/jpegls-home.jpg"/>' . '<figcaption>Some caption to the image</figcaption>' . '</figure>' . '<h1>Big Top Title</h1>' . '<h2>Smaller SubTitle</h2>' . '<time class="op-published" datetime="1984-08-14T19:30:00+00:00">August 14th, 7:30pm</time>' . '<time class="op-modified" datetime="2016-02-10T10:00:00+00:00">February 10th, 10:00am</time>' . '<address>' . '<a>Author One</a>' . 'Passionate coder and mountain biker' . '</address>' . '<address>' . '<a href="http://facebook.com/author" rel="facebook">Author Two</a>' . 'Weend surfer with heavy weight coding skils' . '</address>' . '<h3 class="op-kicker">Some kicker of this article</h3>' . '<section class="op-ad-template">' . '<figure class="op-ad">' . '<iframe src="http://foo.com"></iframe>' . '</figure>' . '<figure class="op-ad op-ad-default">' . '<iframe src="http://foo.com" width="350" height="50"></iframe>' . '</figure>' . '<figure class="op-ad">' . '<iframe width="300" height="250">' . '<script>alert("test & more test");</script>' . '</iframe>' . '</figure>' . '</section>' . '</header>';
$rendered = $header->render();
$this->assertEquals($expected, $rendered);
}
示例5: testImport
public function testImport()
{
$prm = Primitive::time('test')->setSingle(true)->setMax(Time::create('00:12:00'))->setMin(Time::create('00:10:00'));
$array = array(0 => array('test' => '00:12:01'), 1 => array('test' => '00:14:00'), 2 => array('test' => '00:09:59'), 3 => array('test' => '00:11:00'), 4 => array('test' => '00:10:00'), 5 => array('test' => '00:12:00'));
$this->assertFalse($prm->import($array[0]));
$this->assertFalse($prm->import($array[1]));
$this->assertFalse($prm->import($array[2]));
$this->assertTrue($prm->import($array[3]));
$this->assertTrue($prm->import($array[4]));
$this->assertTrue($prm->import($array[5]));
}
示例6: stringToTimeList
public static function stringToTimeList($string)
{
$list = array();
$times = split("([,; \n]+)", $string);
for ($i = 0, $size = count($times); $i < $size; ++$i) {
$time = mb_ereg_replace('[^0-9:]', ':', $times[$i]);
try {
$list[] = Time::create($time);
} catch (WrongArgumentException $e) {
/* ignore */
}
}
return $list;
}
示例7: api_add
public function api_add()
{
$save = Time::create(array('project_name' => 'Projektbezeichnung', 'service_name' => 'Geleisteter Service', 'minutes' => 0, 'created' => strtotime($_POST['date'])));
return Time::last()->id;
}
示例8: getExpireHTML
/**
*
* @return string
*/
public function getExpireHTML()
{
if (!$this->owner->Secured) {
return;
}
if ($this->owner instanceof Folder) {
$ret = "N/A";
} else {
switch ($this->owner->ExpiryType) {
case 'AtAFixedDate':
if ($expireDate = $this->owner->ExpireAtDate) {
$datetime = new SS_Datetime();
$datetime->setValue($expireDate);
$now = $today = date('Y-m-d H:i:s');
if ($expireDate > $now) {
$expire = _t("FileSecured.EmbargoedNotExpired", "Not expired, will expire ");
} else {
$expire = _t("FileSecured.EmbargoedExpired", "Expired ");
}
$time = Time::create();
$time->setValue($datetime->Time());
$date = Date::create();
$date->setValue($datetime->Date());
$ret = $expire . " at " . $time->Nice() . ", " . $date->Long();
} else {
$ret = _t("FileSecured.EmbargoedNoDateSetNotExpired", "No embargoing date/time is set, so treated as not expired");
}
break;
default:
//case 'None':
$ret = "Not expired";
}
}
return $ret;
}
示例9: spawnUser
/**
* @return TestUser
*/
private function spawnUser($options = array())
{
$options += array('id' => '77', 'credentials' => Credentials::create(), 'lastLogin' => Timestamp::create('2011-12-31'), 'registered' => Timestamp::create('2011-12-30'), 'strangeTime' => Time::create('01:23:45'), 'city' => null, 'firstOptional' => null, 'secondOptional' => null, 'url' => HttpUrl::create()->parse('https://www.github.com'), 'properties' => Hstore::make(array('a' => 'apple', 'b' => 'bananas')), 'ip' => IpAddress::create('127.0.0.1'));
return $this->spawnObject(TestUser::create(), $options);
}
示例10: testIsValid
public function testIsValid()
{
$ia = InstantArticle::create()->withCanonicalURL('http://wp.localtest.me/2016/04/12/stress-on-earth/')->enableAutomaticAdPlacement()->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.'));
$this->assertTrue($ia->isValid());
}