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
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);

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.