Jump to content

Get Day from Date


npsari

Recommended Posts

All you need to do is call date with just the day.

echo date('d');

 

If you have a date string like 2008-12-30, you can first convert it to a UNIX timestamp and then you're free to use the date function.

 

$date = '2008-12-30';

// convert to UNIX timestamp
$timestamp = strtotime($date);

echo date('d', $timestamp);

 

Also, if you are getting this date from a MySQL database, you can optionally format it in the query instead.

Link to comment
https://forums.phpfreaks.com/topic/262682-get-day-from-date/#findComment-1346369
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.