Page 1 of 1

Php Date Problem!!

Posted: Thu Mar 18, 2010 5:31 am
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!!

Re: Php Date Problem!!

Posted: Thu Mar 18, 2010 6:17 am
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;
?>

Re: Php Date Problem!!

Posted: Mon Mar 22, 2010 5:07 am
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;
?>