reversing date

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
m2babaey
Forum Contributor
Posts: 364
Joined: Sun May 20, 2007 9:26 am

reversing date

Post by m2babaey »

I need a function that turns dd-mm-yyyy to yyyy-mm-dd
thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Have you tried explode()?
truepal20032001
Forum Commoner
Posts: 27
Joined: Mon Jun 25, 2007 8:28 pm

Post by truepal20032001 »

if you find that in a regular string just do this

Code: Select all

$str = "dd-mm-yyyy";
if(strstr('dd-mm-yyyy ',$str){$str = "yyyy-mm-dd"; }
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post by miro_igov »

truepal20032001 wrote:if you find that in a regular string just do this

Code: Select all

$str = "dd-mm-yyyy";
if(strstr('dd-mm-yyyy ',$str){$str = "yyyy-mm-dd"; }
:lol: :lol:
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post by jmut »

truepal20032001 wrote:if you find that in a regular string just do this

Code: Select all

$str = "dd-mm-yyyy";
if(strstr('dd-mm-yyyy ',$str){$str = "yyyy-mm-dd"; }
This should go in hall of fame :)
m2babaey
Forum Contributor
Posts: 364
Joined: Sun May 20, 2007 9:26 am

Post by m2babaey »

I'm sure explode() and then using dots works ( have not tried)
But this code is so strange to me. will that work?
truepal20032001 wrote:if you find that in a regular string just do this

Code: Select all

$str = "dd-mm-yyyy";
if(strstr('dd-mm-yyyy ',$str){$str = "yyyy-mm-dd"; }
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post by jmut »

m2babaey wrote:I'm sure explode() and then using dots works ( have not tried)
But this code is so strange to me. will that work?
truepal20032001 wrote:if you find that in a regular string just do this

Code: Select all

$str = "dd-mm-yyyy";
if(strstr('dd-mm-yyyy ',$str){$str = "yyyy-mm-dd"; }
It takes less than minute to try out both stuff...don't be so lazy
Post Reply