本文整理汇总了PHP中Carbon::createFromTimestamp方法的典型用法代码示例。如果您正苦于以下问题:PHP Carbon::createFromTimestamp方法的具体用法?PHP Carbon::createFromTimestamp怎么用?PHP Carbon::createFromTimestamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Carbon
的用法示例。
在下文中一共展示了Carbon::createFromTimestamp方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: expired
public function expired($e)
{
$token = \JWTAuth::parseToken();
Config::package('tymon/jwt-auth', 'jwt');
$ttl = Config::get('jwt::refresh_ttl');
$iat = Carbon::createFromTimestamp($token->getPayload()->get('iat'));
$now = Carbon::now();
// if renew ttl is expired too, return 401, otherwise let
// the application generate a new token to frontend
if ($iat->diffInMinutes($now) >= $ttl) {
unset($iat, $now, $ttl);
return response_failure(Lang::get('errors.api.auth.expired'), Config::get('status.error.unauthorized'));
}
unset($iat, $now, $ttl);
}
示例2: datetime
public function datetime()
{
return Carbon::createFromTimestamp(Storage::disk('logs')->lastModified($this->filename));
}
示例3: formattedCreated
public function formattedCreated()
{
$dt = Carbon::createFromTimestamp(strtotime($this->created_at));
$date = $dt->format('d-m-y \\a\\t ga');
// 05-11-2014 at 1pm
return $date;
}
示例4: fileModified
/**
* Return the last modified time
*/
public function fileModified($path)
{
return Carbon::createFromTimestamp($this->disk->lastModified($path));
}
示例5: createUser
/**
* Create a user
*
* @return Create user
* @author Rajiv Seelam
**/
public function createUser($data, $activate = false)
{
$data['birthday'] = \Carbon::createFromTimestamp(strtotime($data['birthday']));
$password = isset($data['password']) ? $data['password'] : str_random(10);
$user = $this->sentry->createUser(array('email' => $data['email'], 'name' => $data['name'], 'password' => $password, 'activated' => $activate));
if (in_array($data['gender'], ['male', 'female'])) {
$user->gender = $data['gender'];
}
if ($data['birthday']) {
$user->birthday = $data['birthday'];
}
if (isset($data['description'])) {
$user->description = strip_tags($data['description']);
}
if (isset($data['image'])) {
$user->photo = $data['image'];
}
$user->save();
return $user;
}
示例6: Subcription
//.........这里部分代码省略.........
}
$quarters_difference--;
$datediff = $quarters_difference;
break;
case "m":
// Number of full months
$months_difference = floor($difference / 2678400);
while (mktime(date("H", $datefrom), date("i", $datefrom), date("s", $datefrom), date("n", $datefrom) + $months_difference, date("j", $dateto), date("Y", $datefrom)) < $dateto) {
$months_difference++;
}
$months_difference--;
$datediff = $months_difference;
break;
case 'y':
// Difference between day numbers
$datediff = date("z", $dateto) - date("z", $datefrom);
break;
case "d":
// Number of full days
$datediff = floor($difference / 86400);
break;
case "w":
// Number of full weekdays
$days_difference = floor($difference / 86400);
$weeks_difference = floor($days_difference / 7);
// Complete weeks
$first_day = date("w", $datefrom);
$days_remainder = floor($days_difference % 7);
$odd_days = $first_day + $days_remainder;
// Do we have a Saturday or Sunday in the remainder?
if ($odd_days > 7) {
// Sunday
$days_remainder--;
}
if ($odd_days > 6) {
// Saturday
$days_remainder--;
}
$datediff = $weeks_difference * 5 + $days_remainder;
break;
case "ww":
// Number of full weeks
$datediff = floor($difference / 604800);
break;
case "h":
// Number of full hours
$datediff = floor($difference / 3600);
break;
case "n":
// Number of full minutes
$datediff = floor($difference / 60);
break;
default:
// Number of full seconds (default)
$datediff = $difference;
break;
}
return $datediff;
}
$fmt = new NumberFormatter('en_US', NumberFormatter::DECIMAL);
switch ($frequency) {
case 1:
//Weekly
$frequency = Frequency::find($frequency)->name;
$recurrences = datediff("ww", $start, $end, false);
$schedule = array();
for ($x = 0; $x <= $recurrences; $x++) {
$schedule[] = Carbon::createFromTimestamp(strtotime($start))->addWeeks($x)->format('m/d/y ');
}
$recurrences = $x;
$amount = $fmt->parse($due) / $x;
break;
case 2:
//Every two weeks
$frequency = Frequency::find($frequency)->name;
$recurrences = round(datediff("ww", $start, $end, false)) / 2;
$schedule = array();
for ($x = 0; $x <= $recurrences; $x++) {
$schedule[] = Carbon::createFromTimestamp(strtotime($start))->addWeeks($x * 2)->format('m/d/y ');
}
$recurrences = $x;
$amount = $fmt->parse($due) / $x;
break;
case 3:
//Monthly
$frequency = Frequency::find($frequency)->name;
$recurrences = datediff("m", $start, $end, false);
$schedule = array();
for ($x = 0; $x <= $recurrences; $x++) {
$schedule[] = Carbon::createFromTimestamp(strtotime($start))->addMonths($x)->format('m/d/y ');
}
$recurrences = $x;
$amount = $fmt->parse($due) / $x;
break;
}
setlocale(LC_MONETARY, "en_US");
$result = array("frequency" => $frequency, "start" => $start, "end" => $end, "subtotal" => money_format('%.2n', round($amount, 2)), "fee" => money_format('%.2n', round($amount / getenv("SV_FEE") - $amount, 2)), "total" => money_format('%.2n', round($amount / getenv("SV_FEE"), 2)), "recurrences" => $recurrences, "dates" => $schedule);
$object = json_decode(json_encode($result), FALSE);
return $object;
}
示例7: lastModifiedAsString
/**
* Returns the item last modification date as string.
*
* @return string Returns the item's last modification date as string.
*/
public function lastModifiedAsString()
{
if (!($date = $this->lastModified)) {
return null;
}
return Carbon::createFromTimestamp($date)->toFormattedDateString();
}
示例8: offers
public function offers($timestamp = 0)
{
$offers = Offer::whereDate('created_at', '>', Carbon::createFromTimestamp($timestamp))->get();
return response()->json($offers->toArray(), 200, [], JSON_UNESCAPED_UNICODE);
}
示例9: getFilterCondition
/**
* Creates a condition string from the passed ExtJs filter definitions
*
* @param $filterString
* @param array $matchExact
* @param bool $returnString
* @param array $callbacks
* @return array|string
* @throws \Exception
*/
public static function getFilterCondition($filterString, $matchExact = ['id', 'o_id'], $returnString = true, $callbacks = [])
{
if (!$filterString) {
return '';
}
$conditions = [];
$filters = json_decode($filterString);
$db = \Pimcore\Db::get();
foreach ($filters as $f) {
if ($f->type == 'string') {
if (in_array($f->property, $matchExact)) {
$conditions[$f->property][] = ' ' . $db->getQuoteIdentifierSymbol() . $f->property . $db->getQuoteIdentifierSymbol() . " = " . $db->quote($f->value) . ' ';
} else {
$conditions[$f->property][] = ' ' . $db->getQuoteIdentifierSymbol() . $f->property . $db->getQuoteIdentifierSymbol() . " LIKE " . $db->quote("%" . $f->value . "%") . ' ';
}
} elseif ($f->type == 'numeric') {
if ($f->operator == 'eq') {
$symbol = ' = ';
} elseif ($f->operator == 'lt') {
$symbol = ' < ';
} elseif ($f->operator == 'gt') {
$symbol = ' > ';
}
$conditions[$f->property][] = ' ' . $db->getQuoteIdentifierSymbol() . $f->property . $db->getQuoteIdentifierSymbol() . $symbol . $db->quote($f->value) . ' ';
} elseif ($f->type == 'date') {
/**
* make sure you pass the date as timestamp
*
* filter: {type : 'date',dateFormat: 'timestamp'}
*/
$date = Carbon::createFromTimestamp($f->value)->setTime(0, 0, 0);
if ($f->operator == 'eq') {
$conditions[$f->property][] = ' ' . $f->property . ' >= ' . $db->quote($date->getTimestamp());
$conditions[$f->property][] = ' ' . $f->property . ' <= ' . $db->quote($date->addDay(1)->subSecond(1)->getTimestamp());
} elseif ($f->operator == 'lt') {
$conditions[$f->property][] = ' ' . $f->property . ' < ' . $db->quote($date->getTimestamp());
} elseif ($f->operator == 'gt') {
$conditions[$f->property][] = ' ' . $f->property . ' > ' . $db->quote($date->addDay(1)->subSecond(1)->getTimestamp());
}
} else {
throw new \Exception("Filer of type " . $f->type . " not jet supported.");
}
}
$conditionsGrouped = [];
foreach ($conditions as $fieldName => $fieldConditions) {
if (count($fieldConditions) > 1) {
$conditionsGrouped[$fieldName] = ' (' . implode(' AND ', $fieldConditions) . ') ';
} else {
$conditionsGrouped[$fieldName] = $fieldConditions[0];
}
}
if ($returnString) {
return implode(' OR ', $conditionsGrouped);
} else {
return $conditionsGrouped;
}
}
示例10: mirrorDay
/**
* mirrorDay
* --------------------------------------------------
* Trying to mirror the specific date, to our DB.
* @param date The date on which we're mirroring.
* --------------------------------------------------
*/
private function mirrorDay($date)
{
foreach ($this->events as $key => $event) {
$eventDate = Carbon::createFromTimestamp($event['created'])->toDateString();
if ($eventDate == $date) {
switch ($event['type']) {
case 'customer.subscription.created':
$this->handleSubscriptionCreation($event);
break;
case 'customer.subscription.updated':
$this->handleSubscriptionUpdate($event);
break;
case 'customer.subscription.deleted':
$this->handleSubscriptionDeletion($event);
break;
default:
}
/* Making sure we're done with the event. */
unset($this->events[$key]);
}
}
}
示例11: deleted
/**
* gets deleted posts,question,answers
* @param array $filter
* @return array|bool
*/
public function deleted($filter = [])
{
try {
if (isset($filter['last_updated'])) {
$filter['deleted_at'] = \Carbon::createFromTimestamp($filter['last_updated'])->toDateTimeString();
}
$data['posts'] = $this->post->deleted($filter);
$data['categories'] = $this->category->deleted($filter);
return $data;
} catch (\Exception $e) {
$this->logger->error($e);
return false;
}
return false;
}