date

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package date provides APOC date/time functions.

This package implements all apoc.date.* functions for working with dates, times, and durations in Cypher queries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(timestamp int64, amount int, unit string) int64

Add adds a duration to a timestamp.

Example:

apoc.date.add(timestamp, 1, 'days') => timestamp + 1 day

func Convert

func Convert(value int64, fromUnit, toUnit string) int64

Convert converts between time units.

Example:

apoc.date.convert(3600, 'seconds', 'hours') => 1

func ConvertFormat

func ConvertFormat(dateStr, fromFormat, toFormat string) string

ConvertFormat converts a date string from one format to another.

Example:

apoc.date.convertFormat('2024-01-15', 'yyyy-MM-dd', 'dd/MM/yyyy')
=> '15/01/2024'

func CurrentTimestamp

func CurrentTimestamp() int64

CurrentTimestamp returns the current Unix timestamp in seconds.

Example:

apoc.date.currentTimestamp() => 1705276800

func Field

func Field(timestamp int64, field string) int

Field extracts a field from a timestamp.

Example:

apoc.date.field(timestamp, 'year') => 2024

func Fields

func Fields(timestamp int64) map[string]int

Fields extracts all fields from a timestamp.

Example:

apoc.date.fields(timestamp)
=> {year:2024, month:1, day:15, ...}

func Format

func Format(timestamp int64, format string) string

Format formats a timestamp as a string.

Example:

apoc.date.format(1705276800, 'yyyy-MM-dd') => '2024-01-15'

func FromISO8601

func FromISO8601(dateStr string) int64

FromISO8601 parses an ISO 8601 date string.

Example:

apoc.date.fromISO8601('2024-01-15T10:30:00Z') => timestamp

func FromUnixTime

func FromUnixTime(timestamp int64) time.Time

FromUnixTime converts from Unix timestamp.

Example:

apoc.date.fromUnixTime(1705276800) => time object

func Parse

func Parse(dateStr, format string) int64

Parse parses a date string with a format.

Example:

apoc.date.parse('2024-01-15', 'yyyy-MM-dd') => timestamp

func ParseAsZonedDateTime

func ParseAsZonedDateTime(dateStr, format string) int64

ParseAsZonedDateTime parses a date with timezone.

Example:

apoc.date.parseAsZonedDateTime('2024-01-15T10:30:00-05:00')

func SystemTimezone

func SystemTimezone() string

SystemTimezone returns the system timezone.

Example:

apoc.date.systemTimezone() => 'America/New_York'

func ToISO8601

func ToISO8601(timestamp int64) string

ToISO8601 formats a timestamp as ISO 8601.

Example:

apoc.date.toISO8601(timestamp) => '2024-01-15T10:30:00Z'

func ToUnixTime

func ToUnixTime(t time.Time) int64

ToUnixTime converts to Unix timestamp (same as currentTimestamp).

Example:

apoc.date.toUnixTime(date) => timestamp

func ToYears

func ToYears(seconds int64) float64

ToYears converts a duration to years (approximate).

Example:

apoc.date.toYears(31536000) => 1 (365 days)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL