Solved

Update date field in MySql

Posted on 2014-01-19
4
803 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now