Date calculations

Post your questions and help other users.

Moderator: Martin

Post Reply
Wibbly
Posts: 418
Joined: 17 Mar 2014 09:02

Date calculations

Post by Wibbly » 28 Jan 2020 14:19

I'd like to add a number of hrs, h, to the current date/time to create a new variable I can use with dateformat to generate a new date/time in the future. Can't seem to get the syntax right.

Anyone know what the expression(s) should look like?

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Date calculations

Post by Desmanto » 28 Jan 2020 18:58

Use addHours();

Code: Select all

houradd = 3;
t = addHours(triggertime, houradd);
Or you can just use the 3 directly.

Code: Select all

t = addHours(triggertime, 3);
{t} now is 3 hours from the triggertime. You can use dateformat later to show in the format you want.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Wibbly
Posts: 418
Joined: 17 Mar 2014 09:02

Re: Date calculations

Post by Wibbly » 29 Jan 2020 11:18

Great - there's always a function I've not yet found!

Post Reply