Convert User entered date and time to Unix Timestamp before inserting to database

This is a discussion on Convert User entered date and time to Unix Timestamp before inserting to database within the PHP Language forums, part of the PHP Programming Forums category; >Much too complicated, DATE_FORMAT() and UNIX_TIMESTAMP() exist in MySQL. I'm somewhat new to MYSQL, so I agree should ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #11 (permalink)  
Old 12-13-2004
scotty
 
Posts: n/a
Default Re: Convert User entered date and time to Unix Timestamp before inserting to database

>Much too complicated, DATE_FORMAT() and UNIX_TIMESTAMP() exist in
MySQL.

I'm somewhat new to MYSQL, so I agree should use existing functions to
perform the translations where possible, depending upon your form input.

Reply With Quote
  #12 (permalink)  
Old 12-13-2004
Michael Fesser
 
Posts: n/a
Default Re: Convert User entered date and time to Unix Timestamp before inserting to database

.oO(scotty)

>>Much too complicated, DATE_FORMAT() and UNIX_TIMESTAMP() exist in

>MySQL.
>
>I'm somewhat new to MYSQL


OK. ;)

>so I agree should use existing functions to
>perform the translations where possible, depending upon your form input.


Yep. You can do much more things in a query than just the usual SELECTs,
even complex calculations and manipulations. If the database is able to
do such things and return any data in any particular format you like,
why not use it? Keeps the PHP code smaller.

Micha
Reply With Quote
  #13 (permalink)  
Old 12-13-2004
scotty
 
Posts: n/a
Default Re: Convert User entered date and time to Unix Timestamp before inserting to database

Thanks for the tip. There is a lot I'm not aware of. New to MYSQL.
In the recent past I created something that involved dates. I just now
changed the data definition you mentioned and it still works fine. The
field is now a DATETIME field but is being created with the same
TIMESTAMP. So it looks like this functions the same but is now
historical rather than the auto-update that you mention?

I look forward to going through my edit routines and inserting some of
the functions mentioned in these comments, where applicable, to make it
more concise where possible. Although I did not ask the original
question here, I appreciate the comments and hope that some of my
original comments helped as well.

Reply With Quote
  #14 (permalink)  
Old 12-13-2004
Michael Fesser
 
Posts: n/a
Default Re: Convert User entered date and time to Unix Timestamp before inserting to database

.oO(scotty)

>Thanks for the tip. There is a lot I'm not aware of. New to MYSQL.
>In the recent past I created something that involved dates. I just now
>changed the data definition you mentioned and it still works fine. The
>field is now a DATETIME field but is being created with the same
>TIMESTAMP. So it looks like this functions the same but is now
>historical rather than the auto-update that you mention?


There are still important differences. It's all explained in the manual.

The DATETIME, DATE, and TIMESTAMP Types
http://dev.mysql.com/doc/mysql/en/DATETIME.html

TIMESTAMP Properties Prior to MySQL 4.1
http://dev.mysql.com/doc/mysql/en/TI...P_pre-4.1.html

TIMESTAMP Properties as of MySQL 4.1
http://dev.mysql.com/doc/mysql/en/TIMESTAMP_4.1.html

Micha
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 09:20 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0