Php Date Problem!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pavanesh2009
Forum Commoner
Posts: 30
Joined: Wed Jan 13, 2010 7:24 am

Php Date Problem!!

Post by pavanesh2009 »

Hi All,

I am using jquery datepicker which takes date in mm-dd-yyyy format, now once user chooses & submit the form I need to convert it's format into yyyy-mm-dd format(mysql-format),

Please suggest how I can make this?tried google but not getting clear idea how to do this.
Thanks in Advance!!
dejvos
Forum Contributor
Posts: 122
Joined: Tue Mar 10, 2009 8:40 am

Re: Php Date Problem!!

Post by dejvos »

I suggest MySQL function if you need it for insert to DB:

Code: Select all

 SELECT STR_TO_DATE('01-31-2010','%m-%d-%Y') 
otherwise it could be

Code: Select all

<?php
list($month,$day,$year) = expldoe("-",$date);
$newDate = $Y."-".$month."-".$day;
?>
pavanesh2009
Forum Commoner
Posts: 30
Joined: Wed Jan 13, 2010 7:24 am

Re: Php Date Problem!!

Post by pavanesh2009 »

Thanks dejvos for help,

Someone told me about php date function & I used it in my script now it works like a charm.
But now I want to filter some records by date (i.e. a duration of week or month), Any idea on this?

Thanks once again!! :D
dejvos wrote:I suggest MySQL function if you need it for insert to DB:

Code: Select all

 SELECT STR_TO_DATE('01-31-2010','%m-%d-%Y') 
otherwise it could be

Code: Select all

<?php
list($month,$day,$year) = expldoe("-",$date);
$newDate = $Y."-".$month."-".$day;
?>
Post Reply