Timestamp
Trait Timestamp.
Table of Contents
Methods
- createFromTimestamp() : static
- Create a Carbon instance from a timestamp and set the timezone (UTC by default).
- createFromTimestampMs() : static
- Create a Carbon instance from a timestamp in milliseconds.
- createFromTimestampMsUTC() : static
- Create a Carbon instance from a timestamp in milliseconds.
- createFromTimestampUTC() : static
- Create a Carbon instance from a timestamp keeping the timezone to UTC.
- getPreciseTimestamp() : float
- Returns a timestamp rounded with the given precision (6 by default).
- getTimestampMs() : int
- Returns the timestamp with millisecond precision.
- timestamp() : static
- Set the instance's timestamp.
- unix() : int
- valueOf() : float
- Returns the milliseconds timestamps used amongst other by Date javascript objects.
- getIntegerAndDecimalParts() : array<string|int, mixed>
- Return an array with integer part digits and decimals digits split from one or more positive numbers (such as timestamps) as string with the given number of decimals (6 by default).
Methods
createFromTimestamp()
Create a Carbon instance from a timestamp and set the timezone (UTC by default).
public
static createFromTimestamp(float|int|string $timestamp[, DateTimeZone|string|int|null $timezone = null ]) : static
Timestamp input can be given as int, float or a string containing one or more numbers.
Parameters
- $timestamp : float|int|string
- $timezone : DateTimeZone|string|int|null = null
Return values
staticcreateFromTimestampMs()
Create a Carbon instance from a timestamp in milliseconds.
public
static createFromTimestampMs(float|int|string $timestamp[, DateTimeZone|string|int|null $timezone = null ]) : static
Timestamp input can be given as int, float or a string containing one or more numbers.
Parameters
- $timestamp : float|int|string
- $timezone : DateTimeZone|string|int|null = null
Return values
staticcreateFromTimestampMsUTC()
Create a Carbon instance from a timestamp in milliseconds.
public
static createFromTimestampMsUTC(float|int|string $timestamp) : static
Timestamp input can be given as int, float or a string containing one or more numbers.
Parameters
- $timestamp : float|int|string
Return values
staticcreateFromTimestampUTC()
Create a Carbon instance from a timestamp keeping the timezone to UTC.
public
static createFromTimestampUTC(float|int|string $timestamp) : static
Timestamp input can be given as int, float or a string containing one or more numbers.
Parameters
- $timestamp : float|int|string
Return values
staticgetPreciseTimestamp()
Returns a timestamp rounded with the given precision (6 by default).
public
getPreciseTimestamp([int $precision = 6 ]) : float
Parameters
- $precision : int = 6
Tags
Return values
floatgetTimestampMs()
Returns the timestamp with millisecond precision.
public
getTimestampMs() : int
Return values
inttimestamp()
Set the instance's timestamp.
public
timestamp(float|int|string $timestamp) : static
Timestamp input can be given as int, float or a string containing one or more numbers.
Parameters
- $timestamp : float|int|string
Return values
staticunix()
public
unix() : int
Tags
Return values
intvalueOf()
Returns the milliseconds timestamps used amongst other by Date javascript objects.
public
valueOf() : float
Return values
floatgetIntegerAndDecimalParts()
Return an array with integer part digits and decimals digits split from one or more positive numbers (such as timestamps) as string with the given number of decimals (6 by default).
private
static getIntegerAndDecimalParts(float|int|string $numbers[, int $decimals = 6 ]) : array<string|int, mixed>
By splitting integer and decimal, this method obtain a better precision than number_format when the input is a string.
Parameters
- $numbers : float|int|string
-
one or more numbers
- $decimals : int = 6
-
number of decimals precision (6 by default)
Return values
array<string|int, mixed> —0-index is integer part, 1-index is decimal part digits