Format dates for SQL Dreamweaver and PHP


show more Formatting dates for SQL provides you with in-depth training on Business. Taught by David Gassner as part of the Dreamweaver with PHP and MySQL show less
please wait ...

Formatting dates for SQL

In a previous video, I described how to use the Record Insertion Wizard to create a data entry form that would collect information from the user and add it to the MySQL database, but I showed that there is a challenge with working with dates. That's because the code that's created by Dreamweaver doesn't do an adequate job of formatting dates as they're expected by MySQL. I'm working in the file, insertfromwizard2.php, in the root folder of the current site. Here is the problem code.

It starts with a case statement, and it's within a function named GetSQLValueString. The case statement for dates assumes that the user has typed in a value in a format that's acceptable to MySQL. Clearly, that isn't always the case. So I'm going to replace this string with a little bit more complex PHP code that uses the Zend_Date class that I've demonstrated in previous videos. I'll go to the top of the file and add a require_once command to incorporate the Zend_Dat...

Formatting dates for SQL
Video duration: 5m 27s 4h 55m Intermediate Updated Jun 12, 2012

Viewers:

Formatting dates for SQL provides you with in-depth training on Business. Taught by David Gassner as part of the Dreamweaver with PHP and MySQL

Subjects:
Business Developer Web
Software:
Dreamweaver
Author:
please wait ...