Jump to content

Archived

This topic is now archived and is closed to further replies.

lxndr

Date question

Recommended Posts

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 ?

Share this post


Link to post
Share on other sites
This should work...
[code]<?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);
?>[/code]

Share this post


Link to post
Share on other sites
[!--quoteo(post=374001:date=May 15 2006, 02:24 PM:name=SemiApocalyptic)--][div class=\'quotetop\']QUOTE(SemiApocalyptic @ May 15 2006, 02:24 PM) [snapback]374001[/snapback][/div][div class=\'quotemain\'][!--quotec--]
This should work...
[code]<?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);
?>[/code]
[/quote]

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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.