Text Size
Sunday, May 20, 2012
Get a look down
JavaScript >> Code snippets >> Get the latest day of a month with PHP
Tuesday, 05 July 2011 09:49

Get the latest day of a month with PHP

Written by Nabil Sadki
Rate this item
(0 votes)

Here's how you can get the latest day for a given month:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
date('t');
// result : the lastest day of the current day
 
$ts = time();
date('t', $ts);
// result : the same result
// PS : $ts is a unix timestamp so you can put any timestamp,
// it will give you the latest day for the month of this timestamp
 
date('Y-m-t');
// result : full date of the last day of the current month. Eg. 2011-07-31
 
date('t',strtotime('last month'));
// You can use strtotime also with a valid date string
Last modified on Monday, 18 July 2011 15:01
Nabil Sadki

Nabil Sadki

Hello, I am Nabyl, a Freelance web developer and a joomla addict. I have made many sites using the latter, but also patches for the core of this CMS. I like HipHop culture and world of warcraft. You can find find me on Twitter when i'm free...

Website: www.coins.ma E-mail: This e-mail address is being protected from spambots. You need JavaScript enabled to view it

Add comment



Usefull tricks