Forum Moderators: coopster

Message Too Old, No Replies

Numbers Fun!

         

gettopreacherman

12:39 am on Mar 4, 2005 (gmt 0)

10+ Year Member



Here's what I have:

04011980

Here's what I want:

April 01, 1980

Any Functions?

ironik

1:13 am on Mar 4, 2005 (gmt 0)

10+ Year Member



This function will take that number format and convert it for you.

<?php
function convertDate($date, $format)
{
$month = substr($date, 0, 2);
$day = substr($date, 2, 2);
$year = substr($date, 4);
$ts = mktime(0,0,0,$month,$day,$year);
return date($format, $ts);
}

echo 'date: ' . convertDate('04011980', 'F d, Y');
// Outputs April 01, 1980
?>

More on date formatting:
[php.net...]

badone

1:22 am on Mar 4, 2005 (gmt 0)

10+ Year Member



<?php
$string = "04011980";

print date( "M d, Y", mktime( 0, 0, 0, substr( $string, 0, 2 ),
substr( $string, 2, 2 ), substr( $string, 4, 4 ) ) );

?>

Cheers,
BAD

badone

1:24 am on Mar 4, 2005 (gmt 0)

10+ Year Member



Sorry ironik, didn't see your post.

Pretty much the same.

You know what they say about great minds..... we don't have them ;-)

Cheers,
BAD

gettopreacherman

5:54 am on Mar 4, 2005 (gmt 0)

10+ Year Member



YOU GUYS ARE FREAKIN AWESOME! Thanks! That's what I needed.

badone

6:19 am on Mar 4, 2005 (gmt 0)

10+ Year Member



You're welcome,

BAD