Welcome, Guest Login

Support Center

Date & Time Calculations

Last Updated: Feb 10, 2017 03:05PM EST
Date & Time Calculation

Tutorial App

Click here to install 'Date & Time' Tutorial app in your environment.


Sometimes you'd like to do some basic calculations with time. Here's a couple of examples of how you can do this.

Time is stored in most computers as "epoch time," the number of seconds since a base point in time. All this means to you is that time is a number and that number goes up by 1 every second.
EachScape lets you get at the time with two expressions [[sys:localTime]] and [[sys:gmtTime]] (Tutorial on how to access these)
The first one gives you the time according to the time zone specified by the user. The second one gives you the time in what is properly called UTC: the time at at the prime meridian ignoring summer or daylight savings time. People often call this GMT Time.

Each of these returns a number. For example
[[sys:localTime]] = "1325776348"

To calculate the time 5 hours from now, here's what needs to be done. Each hour contains 3,600 seconds (60 minutes x 60 seconds). 5 hours equals 18,000 ≈conds (5 hours x 3,600 seconds). This expression
[[sys:localTime:add 18000]] = "1325794348"

gives the value of the time in 5 hours. It can be converted back to a displayable number using the formatDate formatter.

Dividing time by 86,400 seconds (24 hours x 60 minutes x 60 seconds) gives an expression that equals the current date. If you wanted to calculate the date 5 days from now you could divide the sys:localTime or sys:gmtTime value by 432,000.

Finally, it's up to you to decide whether you want to use the localTime or gmtTime value, depending on the application and interpretation. Computer systems typically work with the gmtTime value while people will want to work with the localTime value.

Learn More
- Working with Date & Time
- Formatting Date & Time

Help us improve! Rate this article:

Yes I found this article helpful

Ask a Question   

seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
Invalid characters found