Solved

Update date field in MySql

Posted on 2014-01-19
4
812 Views
Last Modified: 2014-01-19
What a huge @#$%^ mistake.

I took on converting a @#$%^ asp site to php.

Is there any @#$%^ way to update a date field?

PHP or MySQL just wants to update to 0000-00-00 00:00:00

What if 0000-00-00 00:00:00 doesn't work for you?  Let's say someone wasn't born on 0000-00-00 00:00:00 or they didn't start employment on 0000-00-00 00:00:00?  Can @#$%^! MySQL or PHP handle any date other than 0000-00-00 00:00:00?

Even more of a huge leap... can the field not contain a time?

Is there a way in which could look at the field and just see 1/19/2014?
0
Comment
Question by:classnet
  • 2
4 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 39792580
MySQL Date format is YYYY-MM-DD and Time is HH:MM:SS.  Those formats are easy to rearrange for display in PHP but MySQL doesn't want to see any other formats.  Yes, I know the page says it will accept other formats but good luck with that.

MySQL has DATE, TIME, and DATETIME data types.

http://dev.mysql.com/doc/refman/5.6/en/date-and-time-types.html

PHP date function with formatting.

http://us2.php.net/manual/en/function.date.php
0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 39792583
Do you really think php can't accept datetimes different from 0000-00-00 00:00:00? It's evident there is omething wrong with your code. Post it here and maybe we can help.
0
 

Author Closing Comment

by:classnet
ID: 39792597
Thanks dude... time to stop for a while.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39792619
You're welcome.  You are working on a somewhat difficult task.  There is a difference of viewpoints between Classic ASP and PHP.  It would be worse if it were ASP.NET...
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MySQL Backup Strategy 15 44
PHP Soap Server returning XML but < & > as &lt; / &gt; 9 45
Custom Wordpress Loop 22 38
Use Select Query to Return Results as a Form 9 23
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question