#quick question how I can create an irl time system

1 messages · Page 1 of 1 (latest)

steady elk
#

I looked everywhere but I didn't find or didn't understand

tacit sandal
#

Date.now()

steady elk
#

?

steady elk
tacit sandal
#

Date.now() returns the current date in milliseconds

steady elk
#
function date(){
  const date = Date.now()
  world.sendMessage(`${date}`)
}
#

could this work?

tacit sandal
#

no

#

that returns milliseconds

steady elk
#

?

steady elk
tacit sandal
#
function getDate() {
    const date = new Date();
    const hours = date.getHours() + 1;
    const minutes = date.getMinutes();
    const seconds = date.getSeconds();
    world.sendMessage(`${hours}:${minutes}:${seconds}`)
}```
#

@steady elk

#

i see you speak french so thats your timezone

#
  • 1 is reffering to GMT +1
#

so whatever GMT + your time zone is, is how many hours to add

steady elk
plain cove
plain cove
tacit sandal
plain cove
#

prototype is what will construct methods and properties for instances of an object, Date.prototype.toString() means

const date = new Date();
console.warn(date.toString());
tacit sandal
#

well that still doesnt return the current time zone?

#

im EST

plain cove
# tacit sandal im EST

that's probably an issue with the JavaScript environment you're testing your code right now. it should use the system's date to get the local timezone.

plain cove
tacit sandal
#

oh neat

#

didnt know that