Link to home
Start Free TrialLog in
Avatar of doctorbill
doctorbillFlag for United Kingdom of Great Britain and Northern Ireland

asked on

php date format

I have recently updated by database date formats from xx/xx/xxxx to strtotime values (Thanks Ray P) but I still have an application which is working on the old format:

I have a text box on a php page which is sent to another page using GET
The original value in the text box is : 25/09/2012

The url sent is as follows:
?dte1=25%2F09%2F2012

I need to ba able to use a strtotime function  on this on the second page to convert to a time string:
ie
$newvariable = strtotime($_GET[dte1]);

The problem is that the resulting strtotime value is not correct. I can only assume that this is because of the way the string is encoded in the url string initially
Is hrere a way round this ?
ASKER CERTIFIED SOLUTION
Avatar of Barry62
Barry62
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of doctorbill

ASKER

Same problem:

If I use 11/10/2012 as an initial date:

With your suggestion I get 1352505600
The actual figure should be 1349910000

ps I know it should be 1349910000 because that is what has been created in my database when the 11/10/2012 was inserted using the strtotime function a while back
I think you must have transposed some numbers.  The difference between the number you got with my suggestion and what you say the actual number should be is 2595600.  That translates out to 1 month.
Isn't that about
http://php.net/manual/en/function.strtotime.php#106105
... difference with American and European time format ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I managed to get this to work:
$dt1 = strtotime(str_replace("/","-",$_GET[dte1]));

Thanks VERY much for all the wealth of information re. dates - I fully appreciate I need to read up on the subject for the future. I did not know that dates could demand so much attention
Solved