...

View Full Version : Convert 23/01/2012 to 20120123



robbiez
01-23-2012, 06:57 PM
Is it possible to change the date format from 23/01/2012 to 20120123??
Thanks
Rob

mlseim
01-23-2012, 07:03 PM
$date="23/01/2012";
$parts=explode("/",$date);
$newdate=$parts[2].$parts[1].$parts[0];
echo $newdate;

BluePanther
01-23-2012, 07:13 PM
$date="23/01/2012";
$parts=explode("/",$date);
$newdate=$parts[2].$parts[1].$parts[0];
echo $newdate;

Exactly what I was just about to post :D

BluePanther
01-23-2012, 09:49 PM
Wow, got a bad rep point for having a personality, and agreeing with someone.

mlseim
01-23-2012, 09:52 PM
what is a rep point?

BluePanther
01-23-2012, 10:01 PM
Reputation point. Under your name where you have all the green boxes - that's your reputation (kudos btw :thumbsup:). You can see the latest ones on your 'User CP'. You can give neutral, positive or negative points. You give them by clicking the wee medal, next to 'Report post'

mlseim
01-23-2012, 11:07 PM
I guess I never knew what that meant ... what good is it ...
Doesn't look like we can cash it in for anything.

stupid idea.

Fou-Lu
01-24-2012, 12:13 AM
Rep is a builtin feature of the vB3+, and I believe thanks is an extension. They are pretty much the same thing really, except there is no 'chastise user for this post' option :D

Also, another way to do this using 5.3+ uses the datetime:


$sDate = '23/01/2012';
$dt = DateTime::createFromFormat('d/m/Y', $sDate);
print $dt->format('Ymd');

The pro with this is since its an actual datetime type, it is locale aware so you can add a timezone to correct the date if desired.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum