Date and time

10 views
Skip to first unread message

varalflip

unread,
Nov 29, 2016, 7:08:28 PM11/29/16
to Glowscript Users
I need the current date and time in my script, but apparently I can't import the time module. Is there another way to access the time, and correct it for my timezone?

Maurice

Bruce Sherwood

unread,
Nov 29, 2016, 7:19:28 PM11/29/16
to Glowscript Users
Generally speaking, Python modules are not accessible from GlowScript VPython. However, JavaScript functions are accessible. Here are details of the JavaScript Date module:



And here is an example:

d = new Date()
print(d.getFullYear(), d.getMonth()+1, d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds())
Reply all
Reply to author
Forward
0 new messages