Reputation: 15628
I have been given year day (1-366) and I need to figure out which month it is in, how can I do this? Well, I actually have a date string like : year, day or year, minute of day, second and I ultimately want to create a POSIX timestamp from it, how can I do this?
Thank you!
Upvotes: 1
Views: 111
Reputation: 227280
If you have PHP >= 5.3, then you can use DateTime::createFromFormat
.
$day = 176;
$date = DateTime::createFromFormat('z', $day);
echo $date->getTimestamp(); // 1372275280
Upvotes: 6
Reputation: 46900
<?php
$year=2013;
$d=360;
echo date("m",strtotime("1/1/$year + $d days"))
?>
Upvotes: 3
Reputation: 2549
Use the date function to get a posix time stamp.
To get the month of a certain date, use intval(date('m'), mktime($h,$m,$s,$month,$day,$year))
Upvotes: 0