Menu

## Timestamp

Timestamp.php : 21

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()

Timestamp.php : 28

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()

Timestamp.php : 82

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()

Timestamp.php : 62

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()

Timestamp.php : 42

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()

Timestamp.php : 119

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()

Timestamp.php : 139

Returns the timestamp with millisecond precision.

`public getTimestampMs() : int`

##### Return values

int

#### timestamp()

Timestamp.php : 96

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()

Timestamp.php : 151
`public unix() : int`

##### Tags

alias

  getTimestamp

  Returns the UNIX timestamp for the current date.

##### Return values

int

#### valueOf()

Timestamp.php : 129

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

`public valueOf() : float`

##### Return values

float

#### getIntegerAndDecimalParts()

Timestamp.php : 168

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

## Search results