Date on the mac

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
cdinic
Posts: 12
Joined: May 5th, 2008, 4:24 pm

I'm trying to time stamp my errorLog.txt

In the scripting guide there is this example for alerting the current system time:

var timeSrt = system.callSystem("cmd.exe /c \"time/t\"");
alert("Current time is " + timeStr);

How can I accomplish this on the Mac/osx?

In terminal, the command is "date" but I cant' find the method for executing a command in Terminal.

Thanks!
-C
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

How about using the javascript date object? Just google "javascript date" for reference.

Code: Select all

theDate = new Date();
alert(theDate);
hours = theDate.getHours();
alert(hours);
cdinic
Posts: 12
Joined: May 5th, 2008, 4:24 pm

nice! I was thinking to hard.

Thanks,
-C
Post Reply