Nasir Iqbal
Nasir Iqbal

Reputation: 872

strtotime alternative in php 5.1.6

I am successfully using following strtotime command with PHP 5.3

echo strtotime('last day of last month');

but unfortunately same command return empty value in PHP 5.1.6 I don't want to upgrade PHP as PHP 5.1.6 is default version in CentOs 5. I wonder if is there any altertive method to get same result in PHP 5.1.6

Upvotes: 0

Views: 1648

Answers (2)

halfpastfour.am
halfpastfour.am

Reputation: 5933

This should to the trick, mate :D

strtotime('-1 second',strtotime(date('m').'/01/'.date('Y').' 00:00:00'))

If you echo this as a date you'd get 02/28/2011.

Upvotes: 1

powtac
powtac

Reputation: 41060

echo date("t/m/Y", strtotime("last month"));

Upvotes: 2

Related Questions