function month
month(x: number): number

Extracts the month from a Unix timestamp.

Returns a number representing the month for each element in x. Months are 0-indexed, where January is 0 and December is 11.

Examples

Single timestamp

import { assertEquals } from "jsr:@std/assert";

assertEquals(month(1424708525), 1);

Array of timestamps

import { assertEquals } from "jsr:@std/assert";

assertEquals(month([1414886399, 1414972799]), [10, 10]);

Matrix of timestamps

import { assertEquals } from "jsr:@std/assert";

assertEquals(month([[1414886399, 1414972799], [1415059199, 1415145599]]), [[10, 10], [10, 10]]);

Parameters

x: number

A Unix timestamp or an array/matrix of Unix timestamps.

Return Type

number

The month(s) corresponding to the input timestamp(s).

Throws

If the input is not a number, array or matrix.

month(x: array<number>): array<number>

Extracts the month from a Unix timestamp.

Returns a number representing the month for each element in x. Months are 0-indexed, where January is 0 and December is 11.

Examples

Single timestamp

import { assertEquals } from "jsr:@std/assert";

assertEquals(month(1424708525), 1);

Array of timestamps

import { assertEquals } from "jsr:@std/assert";

assertEquals(month([1414886399, 1414972799]), [10, 10]);

Matrix of timestamps

import { assertEquals } from "jsr:@std/assert";

assertEquals(month([[1414886399, 1414972799], [1415059199, 1415145599]]), [[10, 10], [10, 10]]);

Parameters

x: array<number>

A Unix timestamp or an array/matrix of Unix timestamps.

Return Type

array<number>

The month(s) corresponding to the input timestamp(s).

Throws

If the input is not a number, array or matrix.

month(x: matrix<number>): matrix<number>

Extracts the month from a Unix timestamp.

Returns a number representing the month for each element in x. Months are 0-indexed, where January is 0 and December is 11.

Examples

Single timestamp

import { assertEquals } from "jsr:@std/assert";

assertEquals(month(1424708525), 1);

Array of timestamps

import { assertEquals } from "jsr:@std/assert";

assertEquals(month([1414886399, 1414972799]), [10, 10]);

Matrix of timestamps

import { assertEquals } from "jsr:@std/assert";

assertEquals(month([[1414886399, 1414972799], [1415059199, 1415145599]]), [[10, 10], [10, 10]]);

Parameters

x: matrix<number>

A Unix timestamp or an array/matrix of Unix timestamps.

Return Type

matrix<number>

The month(s) corresponding to the input timestamp(s).

Throws

If the input is not a number, array or matrix.