Solved

Update date field in MySql

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

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 30

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 82

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
The viewer will learn how to dynamically set the form action using jQuery.
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…

760 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

23 Experts available now in Live!

Get 1:1 Help Now