dg Posted July 28, 2008 Share Posted July 28, 2008 hi ........all i have the day of the year and year, how to convert it to date format (dd/mm/yyyy) in php thanx dg Quote Link to comment https://forums.phpfreaks.com/topic/116955-solved-php-date/ Share on other sites More sharing options...
ignace Posted July 28, 2008 Share Posted July 28, 2008 date("d-m-Y", mktime($hour, $minute, $second, $day, $year, $month)); mktime() reference: http://be.php.net/manual/en/function.mktime.php date() reference: http://be.php.net/manual/en/function.date.php Quote Link to comment https://forums.phpfreaks.com/topic/116955-solved-php-date/#findComment-601440 Share on other sites More sharing options...
LemonInflux Posted July 28, 2008 Share Posted July 28, 2008 Wouldn't date('d/m/y') work? ---------------- Now playing: Enter Shikari - Adieu via FoxyTunes Quote Link to comment https://forums.phpfreaks.com/topic/116955-solved-php-date/#findComment-601442 Share on other sites More sharing options...
dg Posted July 28, 2008 Author Share Posted July 28, 2008 hi i m not finding the current date ..... i have the year day (that is if it is 2nd jan than i hav 1 as year day) and the year .... for example year_day = 1 year = 2008 so i want function which returns 02/01/2008 thanx Quote Link to comment https://forums.phpfreaks.com/topic/116955-solved-php-date/#findComment-601444 Share on other sites More sharing options...
LemonInflux Posted July 28, 2008 Share Posted July 28, 2008 Hang on, so show us the input you have? If you have '29', '6', '93', surely all you need is implode()? ---------------- Now playing: Enter Shikari - Adieu via FoxyTunes Quote Link to comment https://forums.phpfreaks.com/topic/116955-solved-php-date/#findComment-601449 Share on other sites More sharing options...
dg Posted July 28, 2008 Author Share Posted July 28, 2008 hi ..... i have "z" option of date(); so i have the year day and also year year_day = 364 <------------- this will be 31st decmember and year = 2008 so using year_day n year .... i need the output to be 31/12/2008 hope now it is clear Quote Link to comment https://forums.phpfreaks.com/topic/116955-solved-php-date/#findComment-601456 Share on other sites More sharing options...
Barand Posted July 28, 2008 Share Posted July 28, 2008 <?php $dayOfYear = 364; $year = 2008; echo date ('d/m/Y', strtotime ("+$dayOfYear days $year-01-01")); ?> Quote Link to comment https://forums.phpfreaks.com/topic/116955-solved-php-date/#findComment-601468 Share on other sites More sharing options...
dg Posted July 28, 2008 Author Share Posted July 28, 2008 thanx for the reply ........... it's working Quote Link to comment https://forums.phpfreaks.com/topic/116955-solved-php-date/#findComment-601477 Share on other sites More sharing options...
Barand Posted July 28, 2008 Share Posted July 28, 2008 date("d-m-Y", mktime($hour, $minute, $second, $day, $year, $month)); @ignace your args are in the wrong order. See mktime() reference: http://be.php.net/manual/en/function.mktime.php So this would do it too echo date("d-m-Y", mktime(0, 0, 0, 1, $dayOfYear+1, $year)); Quote Link to comment https://forums.phpfreaks.com/topic/116955-solved-php-date/#findComment-601509 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.