Samuz Posted June 12, 2012 Share Posted June 12, 2012 How would I convert an american date/time into just an english date. e.g 6/11/2012 2:57:23 AM -> 11/6/2012 I could only find functions for manipulating the date, nothing for this type of situation Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted June 12, 2012 Share Posted June 12, 2012 Is this date coming from a database query, or elsewhere? Quote Link to comment Share on other sites More sharing options...
Samuz Posted June 12, 2012 Author Share Posted June 12, 2012 Is this date coming from a database query, or elsewhere? Thank you for your response. It's coming from a gaming site that I scrap data from for statistical purposes and the server time is the format above, i'd like to convert it into the 'english' format so that I can perform database queries based on specific date periods. e.g all results between xx day or xx month. You get the jist. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted June 12, 2012 Share Posted June 12, 2012 date, along with strtotime should work just fine. $raw = "6/11/2012 2:57:23 AM"; $converted = date('d/m/Y', strtotime($raw)); echo $converted; Quote Link to comment Share on other sites More sharing options...
Samuz Posted June 12, 2012 Author Share Posted June 12, 2012 date, along with strtotime should work just fine. $raw = "6/11/2012 2:57:23 AM"; $converted = date('d/m/Y', strtotime($raw)); echo $converted; That was my first idea, but I assumed strtotime() is expecting the format to be dd/mm/yyyy. Whereas this is not the situation and it'd be given me a whole different value? EDIT: Although i'm right, I guess I could always just do date('m/d/Y'); although that seems kinda impractical.. heck would that even work long term? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted June 12, 2012 Share Posted June 12, 2012 What happened when you tried it? Quote Link to comment Share on other sites More sharing options...
Samuz Posted June 12, 2012 Author Share Posted June 12, 2012 Actually nvm, i'm seeing things. Thank you bro! Quote Link to comment Share on other sites More sharing options...
Samuz Posted June 12, 2012 Author Share Posted June 12, 2012 Actually sorry. I'm really confused now. I tried this: $raw = "6/11/2012"; $converted = date('d/m/Y', strtotime($raw)); echo $converted; The date being 6th of Nov 2012. Why's it then coming out as 11/06/2012 ? That's 11th of June?? I'm confused here, anyone mind explaining what is happening? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted June 12, 2012 Share Posted June 12, 2012 You've changed the format from what you originally said it was. You can find the formats that strtotime() works with here: http://us3.php.net/manual/en/datetime.formats.php Quote Link to comment Share on other sites More sharing options...
Samuz Posted June 12, 2012 Author Share Posted June 12, 2012 You've changed the format from what you originally said it was. You can find the formats that strtotime() works with here: http://us3.php.net/manual/en/datetime.formats.php I know but how does 6/11/2012 change into 11/6/2012 is what is confusing me. Quote Link to comment Share on other sites More sharing options...
Jessica Posted June 12, 2012 Share Posted June 12, 2012 You said the first one is an American style date. 6/11/2012 that's month, year day. Then you convert it to day, month year. 11/6/2012 That's still June 11 in day month year. Later you said: "$raw = "6/11/2012"; The date being 6th of Nov 2012." Not in American notation. Which is what you said you were starting with. 6/11/2012 in american is June 11. Is your original value in American or British format? It's either D/M/Y or M/D/Y - figure out which your input is then you can format the output however you like. Quote Link to comment Share on other sites More sharing options...
Samuz Posted June 12, 2012 Author Share Posted June 12, 2012 Okay I think i'm just getting seriously confused between the american format and the english one. I'll mark this thread solved. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.