Semi Monthly Date calculation in PHP

时间:2017-07-12 08:11:15

标签: php date calendar

I am trying to calculate Semi Monthly dates,

  • How to find given date is First half or Second half?

  • First half 1 - 15 Second half 16- End of the month

  • -

1 个答案:

答案 0 :(得分:1)

我已获取日期并将日期格式转换为Y-m-d。

$pick_date = date( 'Y-m-d', $pick_date);

然后我检查给定的日期是上半场还是下半场。

if (date('j', strtotime($pick_date)) <= 15)
{
    echo '1st half';
} else {
    echo '2nd half';
}