Re: newbie - Is there a calendar module for date entry?
| From: | Paul M Foster | Date: | Wed, 22 Jul 2009 16:09:20 +0000 |
| Subject: | Re: newbie - Is there a calendar module for date entry? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-295694@lists.php.net to get a copy of this message | ||
On Wed, Jul 22, 2009 at 08:41:23AM -0700, cool@hosting4days.com wrote:
<snip>
> Another newbie question: storing dates and times...
>
> I'm trying to build a simple notepad page where I can attach a date
> and even time field. So this Tigra or yahoo calendar will be great
> date picker helper.
>
> This is for the US, so I'd like the user to see normal us formatting
> like:
>
> date field - 7/1/2009 and separate time field like: 11:30 AM
>
> mysql can use a DATE or TIME or datetime field type. and seems to use
> a different standard like: YYYY-MM-DD I want to to be able to do date
> calcs and such - so what is the best way (types) to store these
> fields in mysql and display them on the page with php?
The YYYY-MM-DD is an ISO date format which makes date sorting simple. I
typically store dates in this format in databases (though it's usually
configurable).
For outside-database uses, I coded a date class which uses Julian days
as its basic unit of storage. One of the issues I wanted to avoid is the
upcoming "Y2K-like" issue with Unix timestamps. In many places, unix
timestamps are stored as 32 bit integers, which will reach their
capacity, I believe, in 2038. (We'll probably all have 64 bit machines
by then.) Thus, the class generally doesn't consult Unix timestamps This
makes duration and date calculations simple. If you like, I can email
you the class privately.
Store times as a separate field.
Paul
--
Paul M. Foster