How to get the day of the week from a Unix timestamp (PHP)?

horgen picture horgen · Mar 19, 2010 · Viewed 45.9k times · Source

How do I get the day (1-7) from a Unix timestamp in PHP? I also need the day date (1-31) and month (1-12).

Answer

ahmetunal picture ahmetunal · Mar 19, 2010

You can use date() function

$weekday = date('N', $timestamp); // 1-7
$month = date('m', $timestamp); // 1-12
$day = date('d', $timestamp); // 1-31