RE: [PHP] Date () Help please
You could use mktime() with date, too... $first_day = date("w",mktime(0,0,1,$month,1,$year)); Set your $month and $year accordingly. ---John Holmes... > -Original Message- > From: Attila [mailto:[EMAIL PROTECTED]] > Sent: Monday, July 15, 2002 8:07 PM > To: [EMAIL PROTECTED] > Subject: Re: [PHP] Date () Help please > > OK thought I should share in case any needs it but got it to work. Here > is > what it looks like and thanks to Richard Baskett for the help. > > $yr= date (Y); > $mnth = date (F); > $dy= 1; > $string = "$dy $mnth $yr"; > $today = date("w",strtotime($string)); > > Thanks for the help > Attila > http://www.glorynaspiration.com > > > "Attila" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > Ok your way works and thanks for the help but still struggling a little > bit > > here is what I have. > > > > $year = date (Y); //This gets me the current year 2002 > > $month = date (m); //This gets me the current month 07 > > $day= 1; //always looking for the 1st day of the > month > > $string = "$year $month $day"; > > $today = date("w",strtotime($string)); > > echo $today; > > > > My result is: 3 > > > > What am I doing wrong should this work > > > > Thanks for the help > > attila > > http://www.glorynaspiration.com > > > > > > > > > > "Richard Baskett" <[EMAIL PROTECTED]> wrote in message > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > $today = date("w"); // $today will result in '1' > > > $today = date("D"); // $today will result in 'Mon' > > > $today = date("l"); // $today will result in 'Monday' > > > > > > Now if you wanted to feed the script something like this: > > > > > > $string = "01 Jul 2002"; > > > $today = date("l",strtotime($string)); > > > > > > This will result in the long textual day of '01 Jul 2002', so 'Monday' > or > > if > > > you interchange the "l" in the first part of the date function with > "w" > > you > > > will get the the day of the week, numeric, i.e. "0" (Sunday) to "6" > > > (Saturday) or if you use "D" you will get the short textual day so > 'Mon' > > > > > > I hope all of that makes sense to you. Check out the php manual for > the > > > function date and strtotime. > > > > > > http://www.php.net/date > > > http://www.php.net/strtotime > > > > > > Rick > > > > > > "Trust in the Lord with all your heart, And lean not on your own > > > understanding; In all your ways acknowledge Him, And he shall direct > your > > > paths." - Proverbs 3:5-6 > > > > > > > > > > From: "Attila" <[EMAIL PROTECTED]> > > > > Date: Mon, 15 Jul 2002 16:44:39 -0600 > > > > To: [EMAIL PROTECTED] > > > > Subject: [PHP] Date () Help please > > > > > > > > Hello all, > > > > I am very new to PHP and I have added some minor PHP to my > website. > I > > > > would like to make a PHP calander to keep track of things going on. > > Could > > > > someone tell me how I can get the first day of every month. > > > > > > > > For Example: > > > > 01 Jul 2002 was a Monday. > > > > 01 Mar 2002 will be a Thursday > > > > > > > > I need the dates to start my tables so they insert the numbers in > the > > right > > > > day. > > > > > > > > Thanks, > > > > Attila > > > > > > > > > > > > > > > > -- > > > > PHP General Mailing List (http://www.php.net/) > > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date () Help please
OK thought I should share in case any needs it but got it to work. Here is what it looks like and thanks to Richard Baskett for the help. $yr= date (Y); $mnth = date (F); $dy= 1; $string = "$dy $mnth $yr"; $today = date("w",strtotime($string)); Thanks for the help Attila http://www.glorynaspiration.com "Attila" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Ok your way works and thanks for the help but still struggling a little bit > here is what I have. > > $year = date (Y); //This gets me the current year 2002 > $month = date (m); //This gets me the current month 07 > $day= 1; //always looking for the 1st day of the month > $string = "$year $month $day"; > $today = date("w",strtotime($string)); > echo $today; > > My result is: 3 > > What am I doing wrong should this work > > Thanks for the help > attila > http://www.glorynaspiration.com > > > > > "Richard Baskett" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > $today = date("w"); // $today will result in '1' > > $today = date("D"); // $today will result in 'Mon' > > $today = date("l"); // $today will result in 'Monday' > > > > Now if you wanted to feed the script something like this: > > > > $string = "01 Jul 2002"; > > $today = date("l",strtotime($string)); > > > > This will result in the long textual day of '01 Jul 2002', so 'Monday' or > if > > you interchange the "l" in the first part of the date function with "w" > you > > will get the the day of the week, numeric, i.e. "0" (Sunday) to "6" > > (Saturday) or if you use "D" you will get the short textual day so 'Mon' > > > > I hope all of that makes sense to you. Check out the php manual for the > > function date and strtotime. > > > > http://www.php.net/date > > http://www.php.net/strtotime > > > > Rick > > > > "Trust in the Lord with all your heart, And lean not on your own > > understanding; In all your ways acknowledge Him, And he shall direct your > > paths." - Proverbs 3:5-6 > > > > > > > From: "Attila" <[EMAIL PROTECTED]> > > > Date: Mon, 15 Jul 2002 16:44:39 -0600 > > > To: [EMAIL PROTECTED] > > > Subject: [PHP] Date () Help please > > > > > > Hello all, > > > I am very new to PHP and I have added some minor PHP to my website. I > > > would like to make a PHP calander to keep track of things going on. > Could > > > someone tell me how I can get the first day of every month. > > > > > > For Example: > > > 01 Jul 2002 was a Monday. > > > 01 Mar 2002 will be a Thursday > > > > > > I need the dates to start my tables so they insert the numbers in the > right > > > day. > > > > > > Thanks, > > > Attila > > > > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date () Help please
Ok your way works and thanks for the help but still struggling a little bit here is what I have. $year = date (Y); //This gets me the current year 2002 $month = date (m); //This gets me the current month 07 $day= 1; //always looking for the 1st day of the month $string = "$year $month $day"; $today = date("w",strtotime($string)); echo $today; My result is: 3 What am I doing wrong should this work Thanks for the help attila http://www.glorynaspiration.com "Richard Baskett" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > $today = date("w"); // $today will result in '1' > $today = date("D"); // $today will result in 'Mon' > $today = date("l"); // $today will result in 'Monday' > > Now if you wanted to feed the script something like this: > > $string = "01 Jul 2002"; > $today = date("l",strtotime($string)); > > This will result in the long textual day of '01 Jul 2002', so 'Monday' or if > you interchange the "l" in the first part of the date function with "w" you > will get the the day of the week, numeric, i.e. "0" (Sunday) to "6" > (Saturday) or if you use "D" you will get the short textual day so 'Mon' > > I hope all of that makes sense to you. Check out the php manual for the > function date and strtotime. > > http://www.php.net/date > http://www.php.net/strtotime > > Rick > > "Trust in the Lord with all your heart, And lean not on your own > understanding; In all your ways acknowledge Him, And he shall direct your > paths." - Proverbs 3:5-6 > > > > From: "Attila" <[EMAIL PROTECTED]> > > Date: Mon, 15 Jul 2002 16:44:39 -0600 > > To: [EMAIL PROTECTED] > > Subject: [PHP] Date () Help please > > > > Hello all, > > I am very new to PHP and I have added some minor PHP to my website. I > > would like to make a PHP calander to keep track of things going on. Could > > someone tell me how I can get the first day of every month. > > > > For Example: > > 01 Jul 2002 was a Monday. > > 01 Mar 2002 will be a Thursday > > > > I need the dates to start my tables so they insert the numbers in the right > > day. > > > > Thanks, > > Attila > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date () Help please
$today = date("w"); // $today will result in '1' $today = date("D"); // $today will result in 'Mon' $today = date("l"); // $today will result in 'Monday' Now if you wanted to feed the script something like this: $string = "01 Jul 2002"; $today = date("l",strtotime($string)); This will result in the long textual day of '01 Jul 2002', so 'Monday' or if you interchange the "l" in the first part of the date function with "w" you will get the the day of the week, numeric, i.e. "0" (Sunday) to "6" (Saturday) or if you use "D" you will get the short textual day so 'Mon' I hope all of that makes sense to you. Check out the php manual for the function date and strtotime. http://www.php.net/date http://www.php.net/strtotime Rick "Trust in the Lord with all your heart, And lean not on your own understanding; In all your ways acknowledge Him, And he shall direct your paths." - Proverbs 3:5-6 > From: "Attila" <[EMAIL PROTECTED]> > Date: Mon, 15 Jul 2002 16:44:39 -0600 > To: [EMAIL PROTECTED] > Subject: [PHP] Date () Help please > > Hello all, > I am very new to PHP and I have added some minor PHP to my website. I > would like to make a PHP calander to keep track of things going on. Could > someone tell me how I can get the first day of every month. > > For Example: > 01 Jul 2002 was a Monday. > 01 Mar 2002 will be a Thursday > > I need the dates to start my tables so they insert the numbers in the right > day. > > Thanks, > Attila > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Date () Help please
Hello all, I am very new to PHP and I have added some minor PHP to my website. I would like to make a PHP calander to keep track of things going on. Could someone tell me how I can get the first day of every month. For Example: 01 Jul 2002 was a Monday. 01 Mar 2002 will be a Thursday I need the dates to start my tables so they insert the numbers in the right day. Thanks, Attila -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date help (no not that kind)
Hi Sundog, Can help you with dates (but no, if you want that kind you'll definitely not be wanting my advice...) - Original Message - > I am trying to determine if todays date ($today) is within a week > ($startcheck) of a given date ($dob). This is what I have so far. > > $todaydate = (date("Y-d-m")); > $today = strtotime($todaydate); > // $today prior to strtotime = 2001-10-11 > $startcheck = strtotime(2001-08-11); > $dob = strtotime(2001-15-11); > > //$today is CLEARLY between the two dates I'm testing with but "no" is > always returned. > > if($today <= $dob && $startcheck <= $today) { > print "yes"; > } > else { > print "no"; > } > > Here are the values assigned to the vars, why is $today so much smaller > than $startcheck and $dob? > > 1002783600 = today > 1005452940 = startcheck > 1005451980 = dob > > win32 php4 Let's start with "perceptions" because there's a couple here that have the potential to hold you on the side-benches whilst everyone else has a date and has made it to the dance floor... The manual (http://www.php.net/manual/en/function.strtotime.php) says, "strtotime -- Parse about any english [sic] textual datetime description into a UNIX timestamp". The key word is "any" and the fact that it is not "all". > //$today is CLEARLY between the two dates I'm testing with but "no" is > always returned. Er, no - it is not "clear"! A quick geography/horology lesson: the rest of the world either do not use the same date system or do not express the Gregorian calendar the way Americans do. Today no one has a problem with a date written as 11/11/2001, but when 10/11/2001 is written down, does it mean yesterday (10-Nov-2001) or one month back (11-Oct-2001)? In America, the two formats are known as "American" (MM/DD/CCYY) and "European" (DD/MM/CCYY) format. Moving to the format used in the code above (2001). A format of this nature is widely used because it facilitates sorting/comparisons - ah but watch those perceptions, if you were comparing/sorting/performing arithmetic on two dates, one in Oct and one in Nov, then the convention will have to be CCYYMMDD = century, year, month, then day! BTW you will see the logical flow of this ever decreasing period/increasing precision, and how it can be kept going into CCYYMMDDHHMMSS and thereafter depending upon your needs, time base/available utility functions, etc! The function is called 'string to time'. In other words, a series of alphanumeric characters are passed, and a date-time is returned (in the form of a UNIX timestamp). Given that there are many perceptions involved in interpreting what the incoming string of digits means, some dates cannot be unambiguously expressed/resolved (eg yesterday's date). It's always a good idea to add some 'debug echoes' to new code, just to be sure that your perceptions agree with the computer's implacable logic - I added to your code: echo "Todaydate=$todaydate~"; echo "Today=$today~ Startcheck=$startcheck~ DoB=$dob~"; echo "". "Today=".date("Y-M-d",$today). "~ Startcheck=".date("Y-M-d",$startcheck). "~ DoB=".date("Y-M-d",$dob)."~"; and this was returned: Todaydate=2001-11-11~ Today=1005436800~ Startcheck=1005510600~ DoB=1005509700~ Today=2001-Nov-11~ Startcheck=2001-Nov-11~ DoB=2001-Nov-11~no The last "no" is the original output, but before that you can see 'why' - if the date values/definitions are modified, the code works exactly as (I perceive, is) required. Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Date help (no not that kind)
I am trying to determine if todays date ($today) is within a week ($startcheck) of a given date ($dob). This is what I have so far. $todaydate = (date("Y-d-m")); $today = strtotime($todaydate); // $today prior to strtotime = 2001-10-11 $startcheck = strtotime(2001-08-11); $dob = strtotime(2001-15-11); //$today is CLEARLY between the two dates I'm testing with but "no" is always returned. if($today <= $dob && $startcheck <= $today) { print "yes"; } else { print "no"; } Here are the values assigned to the vars, why is $today so much smaller than $startcheck and $dob? 1002783600 = today 1005452940 = startcheck 1005451980 = dob win32 php4 Thanks in advance -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] date HELP !!!!!
I thought this might do it... if( date("d") == date("d",mktime (0,0,0,date("n"),0,0)) ){ echo "last day"; } But it doesn't seem to handle February in non leap years; 8<== $testMktimeArray = array( "7/23/2001", "1/1/2001", "12/31/2001", "2/28/1999", "2/29/1999", "2/28/1999", "2/29/1999", "2/28/2000", "2/29/2000", "2/28/2001", "2/29/2001", "2/28/2002", "2/29/2002", "2/28/2003", "2/29/2003", "2/28/2004", "2/29/2004", "2/28/2005", "2/29/2005", ); foreach( $testMktimeArray as $testDate){ list($m,$d,$y) = explode("/", $testDate); $testTime = mktime (0,0,0,$m,$d,$y); echo "test date \"$testDate\" is ".date("d M Y",$testTime); echo " month is ".date("n",$testTime); echo " End of month is ".date("d",mktime (0,0,0,date("n",$testTime)+1,0,0)).""; if( date("d",$testTime) == date("d",mktime (0,0,0,date("n",$testTime)+1,0,0)) ){ echo "last day"; } } echo ""; 8<== Output; 8<== test date "7/23/2001" is 23 Jul 2001 month is 7 End of month is 31 test date "1/1/2001" is 01 Jan 2001 month is 1 End of month is 31 test date "12/31/2001" is 31 Dec 2001 month is 12 End of month is 31 last day test date "2/28/1999" is 28 Feb 1999 month is 2 End of month is 29 test date "2/29/1999" is 01 Mar 1999 month is 3 End of month is 31 test date "2/28/1999" is 28 Feb 1999 month is 2 End of month is 29 test date "2/29/1999" is 01 Mar 1999 month is 3 End of month is 31 test date "2/28/2000" is 28 Feb 2000 month is 2 End of month is 29 test date "2/29/2000" is 29 Feb 2000 month is 2 End of month is 29 last day test date "2/28/2001" is 28 Feb 2001 month is 2 End of month is 29 test date "2/29/2001" is 01 Mar 2001 month is 3 End of month is 31 test date "2/28/2002" is 28 Feb 2002 month is 2 End of month is 29 test date "2/29/2002" is 01 Mar 2002 month is 3 End of month is 31 test date "2/28/2003" is 28 Feb 2003 month is 2 End of month is 29 test date "2/29/2003" is 01 Mar 2003 month is 3 End of month is 31 test date "2/28/2004" is 28 Feb 2004 month is 2 End of month is 29 test date "2/29/2004" is 29 Feb 2004 month is 2 End of month is 29 last day test date "2/28/2005" is 28 Feb 2005 month is 2 End of month is 29 test date "2/29/2005" is 01 Mar 2005 month is 3 End of month is 31 8<== > -Original Message- > From: Henrik Hansen [mailto:[EMAIL PROTECTED]] > Sent: Monday, 23 July 2001 17:22 > To: [EMAIL PROTECTED] > Subject: Re: [PHP] date HELP ! > > > [EMAIL PROTECTED] (Reductor) wrote: > > > $todaydate = date("m"); > > $tomorrowdate = date("m",time() + 86400); > > if($todaydate != $tomorrowdate){ > >echo "Tomorrow is a new month"; > >} > > or > > if (date("d") == date("j")) > echo "last day"; > > or something else :) > > > > - Original Message - > > From: Yamin Prabudy <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Monday, July 23, 2001 5:27 PM > > Subject: [PHP] date HELP ! > > > >> hi, > >> how do i check that the current date is the end of month > >> > >> Thanks in Advance -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] date HELP !!!!!
Better still, use the date("t"); to find out how many days are in the given month. This part of the date function is a blessing, given the varying days in months, and the fact that we've a leap year every four years. James "Daniel Rezny" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hello Yamin, > > Monday, July 23, 2001, 9:27:46 AM, you wrote: > > YP> hi, > YP> how do i check that the current date is the end of month > > YP> Thanks in Advance > > > If you want to check how long is current month and use this value > later you can use this: > > $month=("m"); //can be like this depend on if you scrolling between > moths. If yes variable $month must be recieved from link. > > $d=27; > while ($d <= 32) { > $mon = date("m",mktime(0,0,0,$month,$d,$rok)); > if ($month != $mon) { > $daylast = $d-1; $d=33; > } > else { > $d++; > } > } > > I hope it helps. > -- > Best regards, > Danielmailto:[EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] date HELP !!!!!
[EMAIL PROTECTED] (Reductor) wrote: > $todaydate = date("m"); > $tomorrowdate = date("m",time() + 86400); > if($todaydate != $tomorrowdate){ >echo "Tomorrow is a new month"; >} or if (date("d") == date("j")) echo "last day"; or something else :) > - Original Message - > From: Yamin Prabudy <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Monday, July 23, 2001 5:27 PM > Subject: [PHP] date HELP ! > >> hi, >> how do i check that the current date is the end of month >> >> Thanks in Advance >> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> To contact the list administrators, e-mail: [EMAIL PROTECTED] >> -- Henrik Hansen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] date HELP !!!!!
Hello Yamin, Monday, July 23, 2001, 9:27:46 AM, you wrote: YP> hi, YP> how do i check that the current date is the end of month YP> Thanks in Advance If you want to check how long is current month and use this value later you can use this: $month=("m"); //can be like this depend on if you scrolling between moths. If yes variable $month must be recieved from link. $d=27; while ($d <= 32) { $mon = date("m",mktime(0,0,0,$month,$d,$rok)); if ($month != $mon) { $daylast = $d-1; $d=33; } else { $d++; } } I hope it helps. -- Best regards, Danielmailto:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] date HELP !!!!!
$todaydate = date("m"); $tomorrowdate = date("m",time() + 86400); if($todaydate != $tomorrowdate){ echo "Tomorrow is a new month"; } - Original Message - From: Yamin Prabudy <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, July 23, 2001 5:27 PM Subject: [PHP] date HELP ! > hi, > how do i check that the current date is the end of month > > Thanks in Advance > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] date HELP !!!!!
hi, how do i check that the current date is the end of month Thanks in Advance -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]