useCase
useCase

Reputation: 1275

Get current date and time form mktime in PHP

I have a problem with find the current date from past mktime. In PHP I find the current date using date("j");. Here I need, suppose my date was in the past year like mktime(0, 0, 0, 2, 1, 2008), then here how can I find the current date of this particular past month.

Upvotes: 0

Views: 3354

Answers (2)

uzyn
uzyn

Reputation: 6683

Either as @octern's solution, or you can do

$day = date('j', strtotime("-2 months"));

or

$day = date('j', strtotime('-30 days'));

depending on your need.

You may also want to refer to strtotime() manual.

Upvotes: 1

octern
octern

Reputation: 4868

Try this:

$date = getdate(mktime(0, 0, 0, 2, 1, 2008));
$day = $date['mday'];

Or just:

$day = date('j', mktime(0, 0, 0, 2, 1, 2008))

Upvotes: 1

Related Questions