Pionia Core

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
static

createFromTimestampMs()

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
static

createFromTimestampMsUTC()

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
static

createFromTimestampUTC()

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
static

getPreciseTimestamp()

Returns a timestamp rounded with the given precision (6 by default).

public getPreciseTimestamp([int $precision = 6 ]) : float
Parameters
$precision : int = 6
Tags
example

getPreciseTimestamp() 1532087464437474 (microsecond maximum precision)

example

getPreciseTimestamp(6) 1532087464437474

example

getPreciseTimestamp(5) 153208746443747 (1/100000 second precision)

example

getPreciseTimestamp(4) 15320874644375 (1/10000 second precision)

example

getPreciseTimestamp(3) 1532087464437 (millisecond precision)

example

getPreciseTimestamp(2) 153208746444 (1/100 second precision)

example

getPreciseTimestamp(1) 15320874644 (1/10 second precision)

example

getPreciseTimestamp(0) 1532087464 (second precision)

example

getPreciseTimestamp(-1) 153208746 (10 second precision)

example

getPreciseTimestamp(-2) 15320875 (100 second precision)

Return values
float

getTimestampMs()

Returns the timestamp with millisecond precision.

public getTimestampMs() : int
Return values
int

timestamp()

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
static

unix()

public unix() : int
Tags
alias

getTimestamp

Returns the UNIX timestamp for the current date.

Return values
int

valueOf()

Returns the milliseconds timestamps used amongst other by Date javascript objects.

public valueOf() : float
Return values
float

getIntegerAndDecimalParts()

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


        
On this page

Search results