Qore Programming Language

  • Increase font size
  • Default font size
  • Decrease font size

How can I add or subtract a variable number of time units from a date/time value (ex: $date - x minutes)?

E-mail Print PDF

How can I add or subtract a variable number of time units from a date/time value (ex: $date - x minutes)?

Use one of the following functions:

  • microseconds()
  • milliseconds()
  • seconds()
  • minutes()
  • hours()
  • days()
  • months()
  • years()

As follows:

# 5 months, 10 days, 20 minutes from now
my int $mo = 5;
my int $d = 10;
my int $mi = 20;
my date $d = now_us() + months($mo) + days($d) + minutes($mi);