Comparing DateTime Structs
Last updated
Was this helpful?
Last updated
Was this helpful?
Remember, comparisons in Elixir using ==/2, >/2, </2 and friends are structural and based on the DateTime struct fields. For proper comparison between datetimes, use the compare/2 function.
As the say, you'll want to use in order to accurately compare two DateTime
structs.
When using compare/2
, you'll get one of :lt
, :gt
, or :eq
as a result, meaning less than, greater than, or equal respectively.