How can I get the timestamp of the next hour?
Example: Something expires in 1 hours, so it would be time.Now() plus one hour
How can I do this?
Thanks!
time.Now().Add(time.Hour)
playground
Related
As far as I understood there's only now() function available in ni-fi expression language to get time. I can easily get 1st day of each month since it is a constant, but how can I get last day of a current month since it varies from month to month?
Thank you beforehand!
${now():format("yyyy-MM-32"):toDate("yyyy-MM-dd"):format("yyyy-MM"):toDate("yyyy-MM"):minus(86400000)}
//^now ^next month ^to date ^1st of next month ^minus 1 day
nifi should provide a function for that...
I have still 981hours for today's month what if I will not consume this hours. In the following month does this 981 hours will reset to 1000 hours ?
Thank you in advance.
Yes. If you don't use some hours at the end of the month, your quota goes back to the base value.
You cannot keep unused dyno hours month over month.
All:
I wonder if there is easy way to group timestamp by order of week, for example:
A month usually has 5 or 4 weeks, once given a timestamp( something like UTC time 1483465353929 which is 1/3/2017 that should be put into 1st week group, say we use the first Monday of a month as the starting of the first week of that month, and if the timestamp is early than the first Monday like 1/1/2017, it should be put into previous month's last week group which is 5th week) How can I quickly identify its week order? Any implementation will be appreciated
Thanks
I want to get a Monday/any particular day from a range of days. The range of days is always a week.
Example: The week is 12/13/2014 - 12/19/2014. If I want to get a Monday/Tuesday from this range, how do I do that?
You can use function NEXT_DAY, for example:
next_day('12/13/2014','MONDAY')
Give you next Monday.
next_day('12/13/2014','TUESDAY')
Give you next Tuesday.
I am setting a redis key with a value which would be there not more than a week. And expiration time set to key will automatically expire the key in first monday morning 8:29 am.
For above result, I have to calculate the expiration time in seconds for current time to coming monday 8:29 +0545.
Ex. if today is Feb 24, Fri 10:00 am then it should calculate time difference from today to coming Monday 8:29 am.
I have done some coding and conditions are ready. The time difference only occurs on time objects. Shall I make the coming Monday 8:29 am a Time object with no date on it and make the operation with current Time object?
Any kind of suggestions and help would be appreciated. Thanks in advance. I have also tried to use time_diff gem but it gives difference on time objects only.
http://api.rubyonrails.org/classes/Time.html#method-i-next_week
To get 8:29 AM of next Monday you could do:
monday = Time.now.next_week + 8.hours + 29.minutes
monday.to_i - Time.now.to_i would then give you the number of seconds from now until that time.