strtotime returning false date

stash_man

I have a problem with strtotime function in php, i'm trying to convert mm-dd-yyyy to yyyy-mm-dd. The date is entered on the text box and on submit it should save the date to the database. the problem is it returns a wrong date(1970-01-01) each time,which means my code isn't taking the variable i use to store the date, My code is:

//dateconvert
$submitdate = date($_POST['date']);
$date   = date("Y-m-d", strtotime($submitdate));

//storeindb
$query ="INSERT INTO ticket SET date = '$date'";
$result = mysql_query($query);

I'm a newbie,please help.

Jonathon

Dates in the m/d/y or d-m-y formats are disambiguated by looking at the separator between the various components: if the separator is a slash (/), then the American m/d/y is assumed; whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed.

http://php.net/manual/en/function.strtotime.php

You need to use the forward slash separator for mm/dd/yyyy formats.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

strtotime() function returning incorrect date

From Dev

PHP date returning blank for Year "2090" with strtotime

From Dev

strtotime return false while converting date string

From Dev

Date formatting returning FALSE

From Dev

Using strtotime() PHP and revert back trough gmdate() is not returning same date

From Dev

strtotime('-1 month') returning wrong date if month have 31 days

From Dev

PHP IF statement with Date not returning False

From Dev

Jasmine date expect always returning false

From Dev

Jasmine date expect always returning false

From Dev

PHP date format and strtotime

From Dev

PHP strtotime returning always midnight

From Dev

Formating date string with strtotime and date

From Dev

strtotime return false for certain dates

From Dev

strtotime returns false on certain dates

From Dev

PHP date conversion using strtotime

From Dev

strtotime to time issue with a specific date

From Dev

strtotime has issues because of date()

From Dev

Formatting date using PHP strtotime

From Dev

strtotime to time issue with a specific date

From Dev

Check a date interval with strtotime in php

From Dev

PHP strtotime returning the wrong result on calculation

From Dev

strtotime always returning 1st january

From Dev

PHP strtotime returning the wrong result on calculation

From Dev

date strtotime() calculation returns 1969 date

From Dev

strtotime doesn't return false with a valid timestamp

From Dev

(PHP) strtotime function false positive with char

From Dev

format of date string for strtotime() function in php

From Dev

String date to time in PHP - strtotime "loses hours"

From Dev

Must be a unixtime or a date/time representation parseable by strtotime

Related Related

HotTag

Archive