Reputation: 153
I just want to know, how to check the timestamp(any month, any year, any date) is present in the current month or not in PHP?
For.eg 1456132659 This is an example timestamp which indicates the last month date. I want a condition like
if(1456132659 is in current month) {
//true
}
else {
//false
}
How can I do this?
Upvotes: 1
Views: 1093
Reputation: 103
You first need to fetch the timestamp of first and last date of current month by using below PHP code-
$first_minute = mktime(0, 0, 0, date("n"), 1);
$last_minute = mktime(23, 59, 0, date("n"), date("t"));
// Now just compare the timestamp for above two values by using below condition
if($timestamp >= $first_minute AND $timestamp <= $last_minute) {
// Your line of code if condtion fullfill.
}
Upvotes: 0
Reputation: 31749
Simply compare the month
-
if(date('m', 1456132659) === date('m')) {
//your code goes here
}
Upvotes: 3