Page 1 of 1

reversing date

Posted: Mon Jul 23, 2007 11:22 pm
by m2babaey
I need a function that turns dd-mm-yyyy to yyyy-mm-dd
thanks

Posted: Mon Jul 23, 2007 11:26 pm
by feyd
Have you tried explode()?

Posted: Mon Jul 23, 2007 11:30 pm
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"; }

Posted: Tue Jul 24, 2007 3:41 am
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:

Posted: Tue Jul 24, 2007 3:45 am
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 :)

Posted: Tue Jul 24, 2007 3:48 am
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"; }

Posted: Tue Jul 24, 2007 3:52 am
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