Hi,
I'm working on a simple workflow that lets the user select a date.
The input type is set to date, and when I look at the date in the system log it looks like this "Fri Sep 21 2018 13:17:17 GMT+0200 (CEST)". I only need the date, not the time, and ideally it should be in this format: dd.mm.yyyy.
Iv'e tried using split, but get this message "Cannot find function split in object". I'm guessing I need to convert the date object to a string but I'm struggling to find out how to do that. With a virtual machine object I do it by assigning vm.name to a new variable. I've been unable to find out if I can do the same with date.
Any suggestions on how to accomplish this will be greatly appreciated. I would like to have the user select a date from a calendar if possible, but I'm open to other ways to accomplish this.
Thanks in advance.
GB
Hello!
Search in the vRO API Explorer for the Scripting Class "Date":
For example you can get the year with "YourDateVar.getFullYear()"
Hello!
Search in the vRO API Explorer for the Scripting Class "Date":
For example you can get the year with "YourDateVar.getFullYear()"
Thanks, Robert.
I keep forgetting about the API explorer. I successfully extracted the desired information using date.getDate(), date.getMonth() and date.getFullYear(). Now I just have to figure out how to pad single digit numbers with a leading zero.
function AddLeadingZero(number) {
return (number < 10 ? '0' : '') + number
}
var day = date.getDate()
var month = date.getMonth() + 1 // getMonth() -> 0 = jan
var year = date.getFullYear()
var fulldate = AddLeadingZero(day) + "." + AddLeadingZero(month) + "." + year
System.log(fulldate)
Great! Thanks a lot, Robert!