Jump to content

[SOLVED] Returing the day of a date?


Solarpitch

Recommended Posts

Hi,

 

I am currently assigning the date in the format of (mdy) to the variable $date. Want I want to do is check if the day is a Sunday. So far I have...

 

<?php

	$d=date(N);

	if ($d=="7")
	{
  		   //do something...
	}

?>

 

but this just checks todays day. I want to check the day of a specific date. So if the user selects a date 3 months in the future I want to see if that date falls on a Sunday.

Link to comment
https://forums.phpfreaks.com/topic/113483-solved-returing-the-day-of-a-date/
Share on other sites

If you use mktime() to take your desired date and turn it into a Unix timestamp, you can use the date() function in the same way you do now but pass it the timestamp you just made with mktime (as, if you don't give date a timestamp to parse, it will assume you want the current timestamp)

 

$userdate = mktime($hour, $minute, $second, $month, $day, $year);

 

 

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.