How to use date and time in Rev
There are many situations where you will want to use the date or the time within your application. Maybe you had a database application and want to store the date whenever you add a record, maybe you want to create a to do list, maybe you just want to time how long something takes.
Rev has built in functions for getting the date and time, in a range of formats. This lesson will show you how to use them.
Getting the date
Different date formats
But what if the date isn't in the format you are used to, for example that date above is in the form m/d/y but here in the UK the more common form is d/m/y.
Rev has a number of different formats for dates, you can specify which form you want the date returned in.
put the long date into field "long"
put the abbreviated date into field "abbreviated"
put the short date into field "short"
put the english date into field "english"
put the system date into field "system"
put the internet date into field "internet"
Converting the date
Formatting the date yourself
If none of the built in formats give you what you need then you can format the date yourself, the easiest way to do this is using the dateItems, this allows you to convert a date to a comma delimited list made up of
* the year
* the month number
* the day of the month
* the hour in 24-hour time
* the minute
* the second
* the numeric day of the week where Sunday is day 1, Monday is day 2, and so forth
You can then use these items to format your date to display however you want. For example
put the date into tDate
convert tDate to dateItems
put "The current day is" && item 3 of tDate & return into tMyFormattedDate
put "The current month is" && item 2 of tDate & return after tMyFormattedDate
put "The current year is" && item 1 of tDate after tMyFormattedDate
put tMyFormattedDate into field "formatted date"
Getting the time
Getting the time is almost exactly the same as getting the date, again just a single line of English
put the time
And similarly you can specify the format you want for the time
put the long time into field "long"
put the abbreviated time into field "abbreviated"
put the short time into field "short"
put the english time into field "english"
put the system time into field "system"
12 and 24 hour time
Coverting the time
Formatting the time yourself
As with the date you can use dateItems to create a custom time format
put the long time into tTime
convert tTime to dateItems
put "The time is" && item 5 of tTime && "minutes and" && item 6 of tTime && "seconds past" && item 4 of tTime into tMyFormattedTime
put tMyFormattedTime into field "formatted time"