Change System Date [Mac] using Applescript or Javascript?
Copy link to clipboard
Copied
Hi All,
Can anyone suggest me how can i change my Mac date using Apple or Java Script.
Is it possible or not? If possible then please suggest.
Shonky
Copy link to clipboard
Copied
It's not possible with AS, and I doubt it is with JS. Normally it's set by pointing to a time server.
Copy link to clipboard
Copied
I had seen Adobe scripting forum using xcopy dos command through Indesign vbscript.
So i think on windows it is possible through dos command and using this dos command with vbscript in indesign but i want same thing on Mac.
Is it possible through Shell script?
Can anybody suggest?
Thanks,
Shonky
Copy link to clipboard
Copied
You might be able to do it using the shell command date, depending on the user's permissions.
But really, it's not something that scripts should be able to change.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Thanks Steven and sstanleyau,
Below is applescript working code.
tell application "Terminal"
do script "systemsetup setdate mm:dd:yy"
end tell
Now i want that applescript start terminal run terminal command and then quit terminal.
Please suggest on it.
Thanks,
Shonky
Copy link to clipboard
Copied
AppleScript has the command 'do shell script' so there is no need to use the terminal app… But I would add to shane's view on changing this setting? Im not going to try it time machine will probably go bananas…
Copy link to clipboard
Copied
Thanks Muppet Mark,
Can you please check below code and suggest me how can i set my old date back.
set oldDate to do shell script "systemsetup -getdate"
do shell script "systemsetup setdate 03:03:10"
--Do some stuff
do shell script "systemsetup setdate " + oldDate
In above code last line not working. Please suggest correct code.
Thanks
Shonky
Copy link to clipboard
Copied
Thanks to all.
Problem solved now .
Here is code.
set oldDate to do shell script "date '+%m:%d:%y'" as string
do shell script "systemsetup setdate 03:03:10"
--Do some stuff
do shell script ("systemsetup setdate " & oldDate)
Shonky

