Your if statement will only be evaluated at the time you connect, so what you want cannot be achieved in this way. Instead you can use the
time parameter of /timer to accomplish the same thing, for example:
/timer 18:28 1 0 /msg #channel foobarThat timer will only trigger once. If you wish to perform the same action every day you can use two timers as so:
on *:CONNECT:{
timer 18:28 1 0 /msg #channel foo
timer 18:28 0 86400 /msg #channel bar
}
The first message (foo) will be sent at 18:28, the second (bar) will be sent 86400 seconds (24 hours) after the first and will repeat at that interval.