glimr/utils/unix_timestamp


Unix Timestamp Utils

Convenience functions for working with Unix timestamps. Returns the current time as integer seconds or nanoseconds since the Unix epoch (January 1, 1970). Useful for storing timestamps in database columns defined with unix_timestamp().

Values

pub fn now() -> Int

Now (Seconds)

Returns the current Unix timestamp in seconds since epoch. Use this for storing timestamps in unix_timestamp() columns.


Example:

let created_at = unix_timestamp.now()
// => 1734700800
pub fn now_nano() -> Int

Now (Nanoseconds)

Returns the nanosecond component of the current timestamp. Useful when you need sub-second precision in addition to the seconds from now().


Example:

let nano = unix_timestamp.now_nano()
// => 123456789
Search Document