Jump to content


Photo

Date question


  • Please log in to reply
2 replies to this topic

#1 lxndr

lxndr
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 15 May 2006 - 10:27 AM

I know that you can output the number of the day of the year using date(z) but is there a simple way of outputting the date in a different format by passing the number of the day of the year instead? e.g. by passing the number 134 to a function you get the output 15th May ?



#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 15 May 2006 - 02:24 PM

This should work...
<?php
function return_date($day,$year=2006) {
    $stamp = mktime(0,0,0,1,$day,$year);
    $date = date("jS F Y",$stamp);
    return $date;
}

echo return_date(134);
?>


#3 lxndr

lxndr
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 15 May 2006 - 03:09 PM

[!--quoteo(post=374001:date=May 15 2006, 02:24 PM:name=SemiApocalyptic)--][div class=\'quotetop\']QUOTE(SemiApocalyptic @ May 15 2006, 02:24 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
This should work...
<?php
function return_date($day,$year=2006) {
    $stamp = mktime(0,0,0,1,$day,$year);
    $date = date("jS F Y",$stamp);
    return $date;
}

echo return_date(134);
?>
[/quote]

Works great! Thanks a bunch, really appreciate the help.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users