Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MrLDarragh

macrumors newbie
Original poster
May 3, 2010
5
0
Code:
delay 1
set thetime to (time string of (current date))
set d to (date string of (current date))
say "Good morning, "
delay 1
say "It is " & d
say thetime
Here it is currently is there a way this could be 12 hour?:confused:
 
I think the format for the time string your system builds up, depends on the location you live. If you run your system in the US, it should give you the proper formatted AM/PM string, if you reside in some of the countries, where a 24-hour system is standard (as where I live) it will be the other way.
(I'm pretty shure, there is likely somebody here to correct me, if I'm wrong!)
So if you run into trouble with that, you can access the properties of your date string individually.

The following code gets the hours and minutes from your actual date string and should give you the proper output -- in the form you want, as I assume.

Code:
set pre to "AM"
set myHour to hours of (current date)
set myMinutes to minutes of (current date)
if (myHour > 12) then
	set myHour to (myHour - 12)
	set pre to "PM"
end if
say (myHour as string)
say (myMinutes as string)
say pre
 
I think the format for the time string your system builds up, depends on the location you live. If you run your system in the US, it should give you the proper formatted AM/PM string, if you reside in some of the countries, where a 24-hour system is standard (as where I live) it will be the other way.
(I'm pretty shure, there is likely somebody here to correct me, if I'm wrong!)
So if you run into trouble with that, you can access the properties of your date string individually.

The following code gets the hours and minutes from your actual date string and should give you the proper output -- in the form you want, as I assume.

Code:
set pre to "AM"
set myHour to hours of (current date)
set myMinutes to minutes of (current date)
if (myHour > 12) then
	set myHour to (myHour - 12)
	set pre to "PM"
end if
say (myHour as string)
say (myMinutes as string)
say pre

Thank you! I can now incorporate that into my script! ;)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.