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 ¶
- func Add(timestamp int64, amount int, unit string) int64
- func Convert(value int64, fromUnit, toUnit string) int64
- func ConvertFormat(dateStr, fromFormat, toFormat string) string
- func CurrentTimestamp() int64
- func Field(timestamp int64, field string) int
- func Fields(timestamp int64) map[string]int
- func Format(timestamp int64, format string) string
- func FromISO8601(dateStr string) int64
- func FromUnixTime(timestamp int64) time.Time
- func Parse(dateStr, format string) int64
- func ParseAsZonedDateTime(dateStr, format string) int64
- func SystemTimezone() string
- func ToISO8601(timestamp int64) string
- func ToUnixTime(t time.Time) int64
- func ToYears(seconds int64) float64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
Add adds a duration to a timestamp.
Example:
apoc.date.add(timestamp, 1, 'days') => timestamp + 1 day
func Convert ¶
Convert converts between time units.
Example:
apoc.date.convert(3600, 'seconds', 'hours') => 1
func ConvertFormat ¶
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 ¶
Field extracts a field from a timestamp.
Example:
apoc.date.field(timestamp, 'year') => 2024
func Fields ¶
Fields extracts all fields from a timestamp.
Example:
apoc.date.fields(timestamp)
=> {year:2024, month:1, day:15, ...}
func Format ¶
Format formats a timestamp as a string.
Example:
apoc.date.format(1705276800, 'yyyy-MM-dd') => '2024-01-15'
func FromISO8601 ¶
FromISO8601 parses an ISO 8601 date string.
Example:
apoc.date.fromISO8601('2024-01-15T10:30:00Z') => timestamp
func FromUnixTime ¶
FromUnixTime converts from Unix timestamp.
Example:
apoc.date.fromUnixTime(1705276800) => time object
func Parse ¶
Parse parses a date string with a format.
Example:
apoc.date.parse('2024-01-15', 'yyyy-MM-dd') => timestamp
func ParseAsZonedDateTime ¶
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 ¶
ToISO8601 formats a timestamp as ISO 8601.
Example:
apoc.date.toISO8601(timestamp) => '2024-01-15T10:30:00Z'
func ToUnixTime ¶
ToUnixTime converts to Unix timestamp (same as currentTimestamp).
Example:
apoc.date.toUnixTime(date) => timestamp
Types ¶
This section is empty.