petebolduc
petebolduc

Reputation: 1263

How to identify the specific hour of the day in PHP?

I am writing a plugin which will send text messages to a clients list but they are on shared hosting with send email limitations by the hour. I need to be able to identify the specific hour of the day when another email is send from the server do I can set up a sent email track log.

I pretty much have the rest of the programming figured out but I do not know how to identify the start of each hour in the day so I can set up the tracking.

Upvotes: 1

Views: 127

Answers (2)

oshell
oshell

Reputation: 9113

If you want to have hours passed today use this:

$currentHoursOfToday=date("H");
echo $currentHoursOfToday;

To save a date using this exact hour use this:

$today=new DateTime("now");
$today->setTime($currentHoursOfToday, 0);
echo $today->format("Y-m-d H\h");

Upvotes: 1

Mikkel Winther
Mikkel Winther

Reputation: 597

mktime() might be what you're looking for.

Upvotes: 2

Related Questions