I need to get the time at the previous 5 minute interval. For example, suppose the time is
03-04-2024 07:16 I want 03-04-2024 07:15
03-04-2024 07:24 I want 03-04-2024 07:20
03-04-2024 07:45 I want 03-04-2024 07:45
I am getting the current time like this
DateTime now = DateTime.timestamp();
But need to work it back. Do I just need to loop by removing a minute until a 0 or 5?
>Solution :
I believe this should work:
now = now.subtract(Duration(minutes: now.minute.remainder(5)));