0

I'm trying to do if statement with the current time,

e.g

if Time is between 14h and 14:30 then ... if time is between 14:30 and 15h then ...

and so on.

time string of (current date)
set Timeleft to missing value

if time string is in "14:00:00" and "14:29:60" then

end if

now obviously time is not a string like i did in my script, how can I make that working?

Also here is my system time format : current date

  --> date "Saturday 9 December 2017 at 14:10:09"
1

Found a work around

set myTime to time string of (current date) as Unicode text
##set Timeleft to missing value

if myTime > "14:00:00" and myTime < "14:30:60" then
    display notification "!"
end if
  • How is this going to work when myTime is going to have AP or PM in it, e.g. 9:45:10 AM – user3439894 Dec 9 '17 at 14:45
  • I don't use AM / PM in my region so I'm fine, but I suppose that wouldn't work – Kevin Dec 9 '17 at 14:47
  • I guess for those that do have AM or PM in myTime one could use the following line of code after the set myTime to time string of ... line: if (last character of myTime as text) is "M" then set myTime to characters 1 through -4 of myTime as text – user3439894 Dec 9 '17 at 15:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .