question

seanbill87 avatar image
seanbill87 asked

In CloudScript: can I access Days, Hours, Minutes from a date?

I tried this code:

 var now = Date.now(); if(now.getHours() > 5 ){  }

I got this Error: JavascriptException

"StackTrace": "TypeError: now.getHours is not a function

How can I get components(Days, Hours) from a Date?

Where I can get all Docs/code/functions usable to cloud script?

appriciate any link/resource.

Thanks.

apisCloudScript
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Andy avatar image
Andy answered

Date.now() returns a number, not a Date object. Instead, you just want to do something like this:

var now = new Date();
if (now.getHours() > 5) {}

Here's some mor einfo about using the Date object in JavaScript: https://www.w3schools.com/js/js_dates.asp

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.