Home
   About Me
   Rene's Resume
   Presentations
   Services
   Rates & Contracts
   Portfolio / Clients
   Demo Apps
   White Papers & Tips
   Tutorials
   Contact Me
 

Other Tidbits

5.1 Dealing with Time

MySQL has a 14 byte datetime type which is very useful. The format of it is yyyyMMddhhmmss where:

y = year
M = month
d = day
h = hours
m = minutes
s = seconds

So 19990317182330 works out to 6:23:30pm on March 17th, 1999.

Having this numeric format is very useful because you can numerically compare dates to see if one is earlier than the other. Having each digit be a month, day, year, etc. means that you can quickly and easily create these dates.

If you are requesting a date from a user, I'd highly recommend setting up a series of pulldown menus to build the date. One select field for each of the year, month, day, hour, etc. It's a lot of HTML to write out but it makes the backend code SO much easier. Just paste the multiple variables together in a string to create your date string.

    $datetime = $year.$month.$day.$hour.$min.$sec;
    

Note: There aren't any corrections for timezone, you'll need to do those on your own. It's difficult with most web applications because the browsers do not export what timezone they are from in the HTTP headers.

5.2 Questions? Comments?

If you have any questions, feel free to send me email at: rene@astutecomputing.com. I can't promise I'll answer your questions but if I've got the spare time, I'll take a shot at it.

5.3 Consulting Services

Of course, part of the reason I put this little tutorial together is to help advertise my own consulting services. Please take a look around the rest of our website if you have a project that you think I could assist you on, please let us know.

 

This page was generated in 0.0010 seconds.
Website content © 2024