Date as a synthetic variable


#1

I need to display the date as an output of a synthetic variable. How is this done?
i.e. I need to output todays date + 2 days as a date
So if it is 23 July + 2 days I need to output 25 July. Are there functions for this?


#2

Greetings, can you please expand a little bit your need, please? Ubidots does not plot in any of its widgets a date but values in a time series, how and where do you need to see the date plotted?

All the best


#3

I need to display a calculated date in a table.
For example, if a tank is loosing water we can calculate how many days it will take to empty based on the current level and the rate at which the level is dropping.
We can then predict the date at which it will be empty by adding the number of days to empty to the current date.
How do add a time period to the current date?
For example if the current level is 80% and the average rate of dropping is 10% per day then it will be empty in 8 days.
Todays date is 23 July. How do I add 23 July + 8 days to get 31 July?


#4

Greetings @ShockWave, from this help article, you can access to the raw variable timestamp using the notation below:

{{var}}.timestamp 

The ‘dot’ operator allows you to access to the variable’s timestamp. Keep in mind that the timestamp is represented as UNIX Posix time in milliseconds.

Hope it helps you.


#5

Hi @jotathebest.
That is very helpful - thank you.
I will get the current time stamp and add the number of days to it (converting the days to milliseconds).
This will give me the future date in unix posix time.
Does ubidots have a built in function to display this time in a human readable format?


#6

Hi there, you may use an HTML Canvas to plot it friendly with the Date() JS object.

All the best