THE BEST NEWSLETTER ANYWHERE
Join 6,000 subscribers and get a daily digest of full stack tutorials delivered to your inbox directly.No spam ever. Unsubscribe any time.
This tutorial explains multiple ways to get Datetime in Local and UTC as well as EPOCH timestamp.
times module has
epochTime() proc that returns a number of milliseconds since the 1970 date.
It returns a floating number.
import std/[times] let currentTimestamp = epochTime() echo currentTimestamp
now() in the
times module returns the current DateTime in Local time.
now().utc in the
times module returns the current UTC date and time
Here is an example
import std/[times] let now1 = now() let now2 = now().utc echo now1 echo now2 echo currentTimestamp
2023-05-02T03:58:03+00:00 2023-05-02T03:58:03Z 1682999883.740629
Recent postsJulia examples - Variable Type Nim example - Convert String to/from the Int How to get length of an array and sequence in Nim? Nim environment variables - read, set, delete, exists, and iterate examples? How to convert from single character to/from string in Nim?