Jump to content

date problem


Samuz

Recommended Posts

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.