Forum Moderators: coopster

Message Too Old, No Replies

Convert Variables to DAY (sun-mon) DATE Functions?

convert variables to date

         

drooh

7:24 am on Mar 28, 2007 (gmt 0)

10+ Year Member



I am trying to figure out if there is way to compute something like the following with PHP

enter Year Month Day output what day of the week it is.

I have a calendar system that has dates logged and id like for it to compute and show what day of the week they are on. does this make sense?

for instance I want it to output something like this

--------
Sun March 25, 2007 4:00pm - 8:30pm
Event One
--------
Tue March 27, 2007 1:00pm - 5:30pm
Event Two
--------
Wed March 28, 2007 5:00pm - 6:00pm
Event One

omoutop

7:45 am on Mar 28, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You can start by checking the strtotime(), mktime() and date() function in the manual. 99% of date calculations use these functions (unless you wish to perform some calculations in your sql)

drooh

7:51 am on Mar 28, 2007 (gmt 0)

10+ Year Member



<?
//set this variable
$initdate = "20020709";

//here is the code
$year = substr ($initdate,0,4);
$month = substr ($initdate,4,2);
$day = substr ($initdate,6,2);

//now display it
$day = date("l", mktime(0,0,0,$month,$day,$year));
echo $day;
?>

this works, thanks!