5

I want to apply a competition event. Winner will be announce at last day of current month. i.e: current month is November. I want to display a message like: Final declaration will be announced at 30th November 10:00:00 pm

I want to get 30th November 10:00:00 pm from php function. Any idea?

Abdus Sattar Bhuiyan
  • 3,016
  • 4
  • 38
  • 72

2 Answers2

5

This produces the same result:

echo date('t F 10:00:00') . "pm";
Rehmat
  • 4,681
  • 3
  • 22
  • 38
1

date returns a formatted date string and accepts the format specifier as the first argument, with an optional second argument as the timestamp. So date alone doesn't get you want you want unless you first calculate the last day of the current month as a Unix timestamp and provide it to date.

You can do this with strtotime, which accepts relative date/times in string form and translates them back to Unix timestamps in integer form.

echo date('jS F g:i:s a', strtotime('last day of this month'));
// should give you something like 30th November 1:02:02 pm
Sherif
  • 11,786
  • 3
  • 32
  • 57