I'll tell you that it's little rougher than you might think, but stay with me. We'll get the dates and times up and running. Here's a script that does nothing more than what it says above. First I'll show you the result of the script and then the script itself. The funny thing about dates and times, and one of the hardest things to get across to students is that computers don't see dates and times like you do.
Computers see only numbers.
You have to force a computer to display text. Furthermore, computers always start their number counts at zero. If the days of the week start with Sunday, then a computer sees Sunday as day zero. That sort off puts computer returns off by one. Further furthermore, this doesn't hold true across elements.