Re: [PHP] Date comparison going wrong, wrong, wrong
Dear Duken, Many thanks for the solution. It worked! And thanks to everyone else who pitched in with various solutions. Regards Terry On 12 November 2012 10:06, Duken Marga dukenma...@gmail.com wrote: Try this: $todaydate = strtotime(date(D, M jS, Y g:i:s a)); $showenddate = strtotime(date(D, M jS, Y g:i:s a, strtotime($showsRecord['end_date']))); if ($todaydate $showenddate): echo The date of the show has not yet arrived; else: echo The show has ended; endif; You must convert both $todaydate and $showendate with strtotime() function, then you can compare them. On Mon, Nov 12, 2012 at 1:30 AM, Terry Ally (Gmail) terrya...@gmail.comwrote: Hi all, I am having a problem with comparing time. I am using the following: $todaydate = date(D, M jS, Y g:i:s a); $showenddate = date(D, M jS, Y g:i:s a, strtotime($showsRecord['end_date'])); if ($todaydate $showenddate): echo The date of the show has not yet arrived; else: echo The show has ended; endif; The problem that I am encountering is that PHP is rendering the reverse of the equation. For example: If today's date is *11 Nov 2012* and the show's end date is *18 Nov 2012*, the message that I am getting is *the show has ended* which is wrong. A test example is at http://www.lakesidesurrey.co.uk/test.php. You can also me what I am doing wrong? Thanks Terry -- Duken Marga -- *Terry Ally* Twitter.com/terryally Facebook.com/terryally ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~ To print or not to print this email is the environmentally-searching question! Which has the highest ecological cost? A sheet of paper or constantly switching on your computer and connecting to the Internet to read your email?
Re: [PHP] Date comparison going wrong, wrong, wrong
On 11/12/2012 02:06 AM, Duken Marga wrote: Try this: $todaydate = strtotime(date(D, M jS, Y g:i:s a)); $showenddate = strtotime(date(D, M jS, Y g:i:s a, strtotime($showsRecord['end_date']))); Won't this give you the same results without the extra conversion steps? $todaydate = date(U); $showenddate = strtotime($showsRecord['end_date']); if ($todaydate $showenddate): echo The date of the show has not yet arrived; else: echo The show has ended; endif; You must convert both $todaydate and $showendate with strtotime() function, then you can compare them. On Mon, Nov 12, 2012 at 1:30 AM, Terry Ally (Gmail)terrya...@gmail.comwrote: Hi all, I am having a problem with comparing time. I am using the following: $todaydate = date(D, M jS, Y g:i:s a); $showenddate = date(D, M jS, Y g:i:s a, strtotime($showsRecord['end_date'])); if ($todaydate $showenddate): echo The date of the show has not yet arrived; else: echo The show has ended; endif; The problem that I am encountering is that PHP is rendering the reverse of the equation. For example: If today's date is *11 Nov 2012* and the show's end date is *18 Nov 2012*, the message that I am getting is *the show has ended* which is wrong. A test example is at http://www.lakesidesurrey.co.uk/test.php. You can also me what I am doing wrong? Thanks Terry -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date comparison going wrong, wrong, wrong
It's a nice shortcut Jim. Never considered that. Thanks. On 20 November 2012 21:03, Jim Lucas li...@cmsws.com wrote: On 11/12/2012 02:06 AM, Duken Marga wrote: Try this: $todaydate = strtotime(date(D, M jS, Y g:i:s a)); $showenddate = strtotime(date(D, M jS, Y g:i:s a, strtotime($showsRecord['end_**date']))); Won't this give you the same results without the extra conversion steps? $todaydate = date(U); $showenddate = strtotime($showsRecord['end_**date']); if ($todaydate $showenddate): echo The date of the show has not yet arrived; else: echo The show has ended; endif; You must convert both $todaydate and $showendate with strtotime() function, then you can compare them. On Mon, Nov 12, 2012 at 1:30 AM, Terry Ally (Gmail)terrya...@gmail.com* *wrote: Hi all, I am having a problem with comparing time. I am using the following: $todaydate = date(D, M jS, Y g:i:s a); $showenddate = date(D, M jS, Y g:i:s a, strtotime($showsRecord['end_**date'])); if ($todaydate $showenddate): echo The date of the show has not yet arrived; else: echo The show has ended; endif; The problem that I am encountering is that PHP is rendering the reverse of the equation. For example: If today's date is *11 Nov 2012* and the show's end date is *18 Nov 2012*, the message that I am getting is *the show has ended* which is wrong. A test example is at http://www.lakesidesurrey.co.**uk/test.phphttp://www.lakesidesurrey.co.uk/test.php . You can also me what I am doing wrong? Thanks Terry -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ -- *Terry Ally* Twitter.com/terryally Facebook.com/terryally ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~ To print or not to print this email is the environmentally-searching question! Which has the highest ecological cost? A sheet of paper or constantly switching on your computer and connecting to the Internet to read your email?
Re: [PHP] Date comparison going wrong, wrong, wrong
On Tue, Nov 13, 2012 at 5:11 AM, Kanishka kanishkani...@gmail.com wrote: if we use a date after 19 January 2038, we can not use 'strtotime' to get timestamp. http://en.wikipedia.org/wiki/Year_2038_problem Only if you're running 32bit OS. If you're running 64bit OS with 64bit PHP you can represent about 580 billion years... - Matijn
Re: [PHP] Date comparison going wrong, wrong, wrong
Terry Ally (Gmail) terrya...@gmail.com hat am 11. November 2012 um 19:30 geschrieben: Hi all, I am having a problem with comparing time. I am using the following: $todaydate = date(D, M jS, Y g:i:s a); $showenddate = date(D, M jS, Y g:i:s a, strtotime($showsRecord['end_date'])); if ($todaydate $showenddate): Read about http://de1.php.net/manual/en/datetime.diff.php echo The date of the show has not yet arrived; else: echo The show has ended; endif; The problem that I am encountering is that PHP is rendering the reverse of the equation. For example: If today's date is *11 Nov 2012* and the show's end date is *18 Nov 2012*, the message that I am getting is *the show has ended* which is wrong. A test example is at http://www.lakesidesurrey.co.uk/test.php. You can also me what I am doing wrong? Thanks Terry -- Marco Behnke Dipl. Informatiker (FH), SAE Audio Engineer Diploma Zend Certified Engineer PHP 5.3 Tel.: 0174 / 9722336 e-Mail: ma...@behnke.biz Softwaretechnik Behnke Heinrich-Heine-Str. 7D 21218 Seevetal http://www.behnke.biz -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date comparison going wrong, wrong, wrong
Try this: $todaydate = strtotime(date(D, M jS, Y g:i:s a)); $showenddate = strtotime(date(D, M jS, Y g:i:s a, strtotime($showsRecord['end_date']))); if ($todaydate $showenddate): echo The date of the show has not yet arrived; else: echo The show has ended; endif; You must convert both $todaydate and $showendate with strtotime() function, then you can compare them. On Mon, Nov 12, 2012 at 1:30 AM, Terry Ally (Gmail) terrya...@gmail.comwrote: Hi all, I am having a problem with comparing time. I am using the following: $todaydate = date(D, M jS, Y g:i:s a); $showenddate = date(D, M jS, Y g:i:s a, strtotime($showsRecord['end_date'])); if ($todaydate $showenddate): echo The date of the show has not yet arrived; else: echo The show has ended; endif; The problem that I am encountering is that PHP is rendering the reverse of the equation. For example: If today's date is *11 Nov 2012* and the show's end date is *18 Nov 2012*, the message that I am getting is *the show has ended* which is wrong. A test example is at http://www.lakesidesurrey.co.uk/test.php. You can also me what I am doing wrong? Thanks Terry -- Duken Marga
Re: [PHP] Date comparison going wrong, wrong, wrong
if we use a date after 19 January 2038, we can not use 'strtotime' to get timestamp. http://en.wikipedia.org/wiki/Year_2038_problem On Mon, Nov 12, 2012 at 3:36 PM, Duken Marga dukenma...@gmail.com wrote: Try this: $todaydate = strtotime(date(D, M jS, Y g:i:s a)); $showenddate = strtotime(date(D, M jS, Y g:i:s a, strtotime($showsRecord['end_date']))); if ($todaydate $showenddate): echo The date of the show has not yet arrived; else: echo The show has ended; endif; You must convert both $todaydate and $showendate with strtotime() function, then you can compare them. On Mon, Nov 12, 2012 at 1:30 AM, Terry Ally (Gmail) terrya...@gmail.com wrote: Hi all, I am having a problem with comparing time. I am using the following: $todaydate = date(D, M jS, Y g:i:s a); $showenddate = date(D, M jS, Y g:i:s a, strtotime($showsRecord['end_date'])); if ($todaydate $showenddate): echo The date of the show has not yet arrived; else: echo The show has ended; endif; The problem that I am encountering is that PHP is rendering the reverse of the equation. For example: If today's date is *11 Nov 2012* and the show's end date is *18 Nov 2012*, the message that I am getting is *the show has ended* which is wrong. A test example is at http://www.lakesidesurrey.co.uk/test.php. You can also me what I am doing wrong? Thanks Terry -- Duken Marga
Re: [PHP] Date comparison going wrong, wrong, wrong
You can always use timestamp which is integer. $todaydate = time(); $showenddate = strtotime($showsRecord['end_date']); On Mon, Nov 12, 2012 at 12:30 AM, Terry Ally (Gmail) terrya...@gmail.comwrote: Hi all, I am having a problem with comparing time. I am using the following: $todaydate = date(D, M jS, Y g:i:s a); $showenddate = date(D, M jS, Y g:i:s a, strtotime($showsRecord['end_date'])); if ($todaydate $showenddate): echo The date of the show has not yet arrived; else: echo The show has ended; endif; The problem that I am encountering is that PHP is rendering the reverse of the equation. For example: If today's date is *11 Nov 2012* and the show's end date is *18 Nov 2012*, the message that I am getting is *the show has ended* which is wrong. A test example is at http://www.lakesidesurrey.co.uk/test.php. You can also me what I am doing wrong? Thanks Terry -- Shiplu.Mokadd.im ImgSign.com | A dynamic signature machine Innovation distinguishes between follower and leader
Re: [PHP] Date comparison going wrong, wrong, wrong
On 11 Nov 2012, at 18:30, Terry Ally (Gmail) terrya...@gmail.com wrote: I am having a problem with comparing time. I am using the following: $todaydate = date(D, M jS, Y g:i:s a); $showenddate = date(D, M jS, Y g:i:s a, strtotime($showsRecord['end_date'])); The date function returns a string. if ($todaydate $showenddate): echo The date of the show has not yet arrived; else: echo The show has ended; endif; So here you are comparing two strings; PHP has no idea they are dates. The problem that I am encountering is that PHP is rendering the reverse of the equation. For example: If today's date is *11 Nov 2012* and the show's end date is *18 Nov 2012*, the message that I am getting is *the show has ended* which is wrong. A test example is at http://www.lakesidesurrey.co.uk/test.php. You can also me what I am doing wrong? Compare timestamps instead, i.e. time() for the current time, and what you get back from strtotime for the end date. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/
Re: [PHP] Date comparison going wrong, wrong, wrong
Hi Shiplu and Stuart, Comparing timestamps was my first option. I've reinstated it. Have a look at http://www.lakesidesurrey.co.uk/test.php (show_source included) and you will see that PHP is still outputting the wrong thing. I just can't figure out what's wrong. Terry On 11 November 2012 18:48, shiplu shiplu@gmail.com wrote: You can always use timestamp which is integer. $todaydate = time(); $showenddate = strtotime($showsRecord['end_date']); On Mon, Nov 12, 2012 at 12:30 AM, Terry Ally (Gmail) terrya...@gmail.comwrote: Hi all, I am having a problem with comparing time. I am using the following: $todaydate = date(D, M jS, Y g:i:s a); $showenddate = date(D, M jS, Y g:i:s a, strtotime($showsRecord['end_date'])); if ($todaydate $showenddate): echo The date of the show has not yet arrived; else: echo The show has ended; endif; The problem that I am encountering is that PHP is rendering the reverse of the equation. For example: If today's date is *11 Nov 2012* and the show's end date is *18 Nov 2012*, the message that I am getting is *the show has ended* which is wrong. A test example is at http://www.lakesidesurrey.co.uk/test.php. You can also me what I am doing wrong? Thanks Terry -- Shiplu.Mokadd.im ImgSign.com | A dynamic signature machine Innovation distinguishes between follower and leader -- *Terry Ally* Twitter.com/terryally Facebook.com/terryally ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~ To print or not to print this email is the environmentally-searching question! Which has the highest ecological cost? A sheet of paper or constantly switching on your computer and connecting to the Internet to read your email?
Re: [PHP] Date comparison going wrong, wrong, wrong
On 11 Nov 2012, at 19:00, Terry Ally (Gmail) terrya...@gmail.com wrote: Hi Shiplu and Stuart, Comparing timestamps was my first option. I've reinstated it. Have a look at http://www.lakesidesurrey.co.uk/test.php (show_source included) and you will see that PHP is still outputting the wrong thing. I just can't figure out what's wrong. Your comparison is backwards: if ($todaydate $showenddate): should be if ($todaydate $showenddate): -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ On 11 November 2012 18:48, shiplu shiplu@gmail.com wrote: You can always use timestamp which is integer. $todaydate = time(); $showenddate = strtotime($showsRecord['end_date']); On Mon, Nov 12, 2012 at 12:30 AM, Terry Ally (Gmail) terrya...@gmail.comwrote: Hi all, I am having a problem with comparing time. I am using the following: $todaydate = date(D, M jS, Y g:i:s a); $showenddate = date(D, M jS, Y g:i:s a, strtotime($showsRecord['end_date'])); if ($todaydate $showenddate): echo The date of the show has not yet arrived; else: echo The show has ended; endif; The problem that I am encountering is that PHP is rendering the reverse of the equation. For example: If today's date is *11 Nov 2012* and the show's end date is *18 Nov 2012*, the message that I am getting is *the show has ended* which is wrong. A test example is at http://www.lakesidesurrey.co.uk/test.php. You can also me what I am doing wrong? Thanks Terry -- Shiplu.Mokadd.im ImgSign.com | A dynamic signature machine Innovation distinguishes between follower and leader -- *Terry Ally* Twitter.com/terryally Facebook.com/terryally ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~ To print or not to print this email is the environmentally-searching question! Which has the highest ecological cost? A sheet of paper or constantly switching on your computer and connecting to the Internet to read your email? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date comparison going wrong, wrong, wrong
Please include the list when replying. On 11 Nov 2012, at 19:08, Terry Ally (Gmail) terrya...@gmail.com wrote: What I want is the reverse. I want that if people attempt to access the show page after the show has ended that it triggers an error which takes it to another page. The actual conditional statement is as follows (which I will replace with timestamp): $todaydate = date(D, M jS, Y g:i:s a); $showenddate = date(D, M jS, Y g:i:s a, strtotime($showsRecord['end_date'])); if ($todaydate $showenddate) { header( 'Location: eventdetails_error.php' ) ; } This is what you have: if ($todaydate $showenddate): echo The date of the show has not yet arrivedbr; else: echo The show has endedbr; endif; That says: if the current time is later than the end date of the show, tell them the date of the show hasn't arrived yet. What you mean is: if the current time is later than the end of the show, tell them the show has ended. if ($todaydate $showenddate): echo The date of the show has not yet arrivedbr; else: echo The show has endedbr; endif; It's a simple logic error. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ On 11 November 2012 19:04, Stuart Dallas stu...@3ft9.com wrote: On 11 Nov 2012, at 19:00, Terry Ally (Gmail) terrya...@gmail.com wrote: Hi Shiplu and Stuart, Comparing timestamps was my first option. I've reinstated it. Have a look at http://www.lakesidesurrey.co.uk/test.php (show_source included) and you will see that PHP is still outputting the wrong thing. I just can't figure out what's wrong. Your comparison is backwards: if ($todaydate $showenddate): should be if ($todaydate $showenddate): -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ On 11 November 2012 18:48, shiplu shiplu@gmail.com wrote: You can always use timestamp which is integer. $todaydate = time(); $showenddate = strtotime($showsRecord['end_date']); On Mon, Nov 12, 2012 at 12:30 AM, Terry Ally (Gmail) terrya...@gmail.comwrote: Hi all, I am having a problem with comparing time. I am using the following: $todaydate = date(D, M jS, Y g:i:s a); $showenddate = date(D, M jS, Y g:i:s a, strtotime($showsRecord['end_date'])); if ($todaydate $showenddate): echo The date of the show has not yet arrived; else: echo The show has ended; endif; The problem that I am encountering is that PHP is rendering the reverse of the equation. For example: If today's date is *11 Nov 2012* and the show's end date is *18 Nov 2012*, the message that I am getting is *the show has ended* which is wrong. A test example is at http://www.lakesidesurrey.co.uk/test.php. You can also me what I am doing wrong? Thanks Terry -- Shiplu.Mokadd.im ImgSign.com | A dynamic signature machine Innovation distinguishes between follower and leader -- *Terry Ally* Twitter.com/terryally Facebook.com/terryally ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~ To print or not to print this email is the environmentally-searching question! Which has the highest ecological cost? A sheet of paper or constantly switching on your computer and connecting to the Internet to read your email? -- Terry Ally Twitter.com/terryally Facebook.com/terryally ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~ To print or not to print this email is the environmentally-searching question! Which has the highest ecological cost? A sheet of paper or constantly switching on your computer and connecting to the Internet to read your email? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date comparison going wrong, wrong, wrong
Stuart, I reversed it as you suggested and every future show is displaying as having ended. Terry On 11 November 2012 19:11, Stuart Dallas stu...@3ft9.com wrote: Please include the list when replying. On 11 Nov 2012, at 19:08, Terry Ally (Gmail) terrya...@gmail.com wrote: What I want is the reverse. I want that if people attempt to access the show page after the show has ended that it triggers an error which takes it to another page. The actual conditional statement is as follows (which I will replace with timestamp): $todaydate = date(D, M jS, Y g:i:s a); $showenddate = date(D, M jS, Y g:i:s a, strtotime($showsRecord['end_date'])); if ($todaydate $showenddate) { header( 'Location: eventdetails_error.php' ) ; } This is what you have: if ($todaydate $showenddate): echo The date of the show has not yet arrivedbr; else: echo The show has endedbr; endif; That says: if the current time is later than the end date of the show, tell them the date of the show hasn't arrived yet. What you mean is: if the current time is later than the end of the show, tell them the show has ended. if ($todaydate $showenddate): echo The date of the show has not yet arrivedbr; else: echo The show has endedbr; endif; It's a simple logic error. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ On 11 November 2012 19:04, Stuart Dallas stu...@3ft9.com wrote: On 11 Nov 2012, at 19:00, Terry Ally (Gmail) terrya...@gmail.com wrote: Hi Shiplu and Stuart, Comparing timestamps was my first option. I've reinstated it. Have a look at http://www.lakesidesurrey.co.uk/test.php (show_source included) and you will see that PHP is still outputting the wrong thing. I just can't figure out what's wrong. Your comparison is backwards: if ($todaydate $showenddate): should be if ($todaydate $showenddate): -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ On 11 November 2012 18:48, shiplu shiplu@gmail.com wrote: You can always use timestamp which is integer. $todaydate = time(); $showenddate = strtotime($showsRecord['end_date']); On Mon, Nov 12, 2012 at 12:30 AM, Terry Ally (Gmail) terrya...@gmail.comwrote: Hi all, I am having a problem with comparing time. I am using the following: $todaydate = date(D, M jS, Y g:i:s a); $showenddate = date(D, M jS, Y g:i:s a, strtotime($showsRecord['end_date'])); if ($todaydate $showenddate): echo The date of the show has not yet arrived; else: echo The show has ended; endif; The problem that I am encountering is that PHP is rendering the reverse of the equation. For example: If today's date is *11 Nov 2012* and the show's end date is *18 Nov 2012*, the message that I am getting is *the show has ended* which is wrong. A test example is at http://www.lakesidesurrey.co.uk/test.php. You can also me what I am doing wrong? Thanks Terry -- Shiplu.Mokadd.im ImgSign.com | A dynamic signature machine Innovation distinguishes between follower and leader -- *Terry Ally* Twitter.com/terryally Facebook.com/terryally ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~ To print or not to print this email is the environmentally-searching question! Which has the highest ecological cost? A sheet of paper or constantly switching on your computer and connecting to the Internet to read your email? -- Terry Ally Twitter.com/terryally Facebook.com/terryally ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~ To print or not to print this email is the environmentally-searching question! Which has the highest ecological cost? A sheet of paper or constantly switching on your computer and connecting to the Internet to read your email? -- *Terry Ally* Twitter.com/terryally Facebook.com/terryally ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~ To print or not to print this email is the environmentally-searching question! Which has the highest ecological cost? A sheet of paper or constantly switching on your computer and connecting to the Internet to read your email?
Re: [PHP] Date comparison going wrong, wrong, wrong
On 11 Nov 2012, at 19:24, Terry Ally (Gmail) terrya...@gmail.com wrote: I reversed it as you suggested and every future show is displaying as having ended. In that case the code you're showing us is not the code you're running, because that's the obvious error in test.php. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ On 11 November 2012 19:11, Stuart Dallas stu...@3ft9.com wrote: Please include the list when replying. On 11 Nov 2012, at 19:08, Terry Ally (Gmail) terrya...@gmail.com wrote: What I want is the reverse. I want that if people attempt to access the show page after the show has ended that it triggers an error which takes it to another page. The actual conditional statement is as follows (which I will replace with timestamp): $todaydate = date(D, M jS, Y g:i:s a); $showenddate = date(D, M jS, Y g:i:s a, strtotime($showsRecord['end_date'])); if ($todaydate $showenddate) { header( 'Location: eventdetails_error.php' ) ; } This is what you have: if ($todaydate $showenddate): echo The date of the show has not yet arrivedbr; else: echo The show has endedbr; endif; That says: if the current time is later than the end date of the show, tell them the date of the show hasn't arrived yet. What you mean is: if the current time is later than the end of the show, tell them the show has ended. if ($todaydate $showenddate): echo The date of the show has not yet arrivedbr; else: echo The show has endedbr; endif; It's a simple logic error. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ On 11 November 2012 19:04, Stuart Dallas stu...@3ft9.com wrote: On 11 Nov 2012, at 19:00, Terry Ally (Gmail) terrya...@gmail.com wrote: Hi Shiplu and Stuart, Comparing timestamps was my first option. I've reinstated it. Have a look at http://www.lakesidesurrey.co.uk/test.php (show_source included) and you will see that PHP is still outputting the wrong thing. I just can't figure out what's wrong. Your comparison is backwards: if ($todaydate $showenddate): should be if ($todaydate $showenddate): -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ On 11 November 2012 18:48, shiplu shiplu@gmail.com wrote: You can always use timestamp which is integer. $todaydate = time(); $showenddate = strtotime($showsRecord['end_date']); On Mon, Nov 12, 2012 at 12:30 AM, Terry Ally (Gmail) terrya...@gmail.comwrote: Hi all, I am having a problem with comparing time. I am using the following: $todaydate = date(D, M jS, Y g:i:s a); $showenddate = date(D, M jS, Y g:i:s a, strtotime($showsRecord['end_date'])); if ($todaydate $showenddate): echo The date of the show has not yet arrived; else: echo The show has ended; endif; The problem that I am encountering is that PHP is rendering the reverse of the equation. For example: If today's date is *11 Nov 2012* and the show's end date is *18 Nov 2012*, the message that I am getting is *the show has ended* which is wrong. A test example is at http://www.lakesidesurrey.co.uk/test.php. You can also me what I am doing wrong? Thanks Terry -- Shiplu.Mokadd.im ImgSign.com | A dynamic signature machine Innovation distinguishes between follower and leader -- *Terry Ally* Twitter.com/terryally Facebook.com/terryally ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~ To print or not to print this email is the environmentally-searching question! Which has the highest ecological cost? A sheet of paper or constantly switching on your computer and connecting to the Internet to read your email? -- Terry Ally Twitter.com/terryally Facebook.com/terryally ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~ To print or not to print this email is the environmentally-searching question! Which has the highest ecological cost? A sheet of paper or constantly switching on your computer and connecting to the Internet to read your email? -- Terry Ally Twitter.com/terryally Facebook.com/terryally ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~ To print or not to print this email is the environmentally-searching question! Which has the highest ecological cost? A sheet of paper or constantly switching on your computer and connecting to the Internet to read your email?
Re: [PHP] Date Comparison
Telling someone RTFM is just rude and mean. Manipulating dates and times can be confusing for beginners and experienced people alike. I would suggest that when a question asked here causes you to respond with RTFM, don't respond at all. Save yourself the time and trouble and save the person asking the question the grief of being insulted. And Tedd your condescending response caused me to lose respect for you. I'm sure the OP would have been more than thankful to receive the same response without the RTFM. I'll read any response to this, but I won't have anything more to say. This list has been polluted enough lately with nonsense. Incredible. On Sat, Aug 29, 2009 at 3:44 PM, tedd tedd.sperl...@gmail.com wrote: At 1:01 PM -0400 8/28/09, David Stoltz wrote: Hey Stuart - RTFM yourselfI did read it, and obviously misunderstood... I'm really sorry to bother you. I thought that was what a listserv like this was for - to ask questions... I'll try not to ask questions I should know the answer to next time. Whoa dude! You just received advice from a brilliant man and you are bitching about it?!? Look child, you are being told what you should do by a professional who is donating his time freely to help you. Just how did you not understand that? So, just do what he advised and say Thank you sir, may I have another? I've posted some dumb-ass questions before, but only after I took the time to research the question myself. And when someone took the time to straighten me out and help, I appreciated it. Hopefully next time you'll read the manual and take the time to understand what you read -- it would cut down on post that demonstrate just how ignorant and thankless you are at this. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date Comparison
2009/9/3 J DeBord jasdeb...@gmail.com: Telling someone RTFM is just rude and mean. Manipulating dates and times can be confusing for beginners and experienced people alike. I would suggest that when a question asked here causes you to respond with RTFM, don't respond at all. Save yourself the time and trouble and save the person asking the question the grief of being insulted. And Tedd your condescending response caused me to lose respect for you. I'm sure the OP would have been more than thankful to receive the same response without the RTFM. I'll read any response to this, but I won't have anything more to say. This list has been polluted enough lately with nonsense. Incredible. You're entitled to your opinion as much as I am, and my opinion is that not making it clear to people that the answer to their question is plainly obvious in the manual is just as rude if not more so than suggesting they RTFM. I make a point to never just say RTFM but to also answer the question at the same time, but IMHO not telling people how fundamental their question was does not help them in the long run. At the end of the day it just encourages them to continue to rely on this list rather than learning how to find the answer themselves and to only use this list as a last resort. I make no apology for my attitude towards this type of question, and if you don't like it you can stick it where the sun don't shine. -Stuart -- http://stut.net/ On Sat, Aug 29, 2009 at 3:44 PM, tedd tedd.sperl...@gmail.com wrote: At 1:01 PM -0400 8/28/09, David Stoltz wrote: Hey Stuart - RTFM yourselfI did read it, and obviously misunderstood... I'm really sorry to bother you. I thought that was what a listserv like this was for - to ask questions... I'll try not to ask questions I should know the answer to next time. Whoa dude! You just received advice from a brilliant man and you are bitching about it?!? Look child, you are being told what you should do by a professional who is donating his time freely to help you. Just how did you not understand that? So, just do what he advised and say Thank you sir, may I have another? I've posted some dumb-ass questions before, but only after I took the time to research the question myself. And when someone took the time to straighten me out and help, I appreciated it. Hopefully next time you'll read the manual and take the time to understand what you read -- it would cut down on post that demonstrate just how ignorant and thankless you are at this. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- 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 Comparison
On Thu, Sep 03, 2009 at 10:20:49AM +0100, Stuart wrote: 2009/9/3 J DeBord jasdeb...@gmail.com: Telling someone RTFM is just rude and mean. Manipulating dates and times can be confusing for beginners and experienced people alike. I would suggest that when a question asked here causes you to respond with RTFM, don't respond at all. Save yourself the time and trouble and save the person asking the question the grief of being insulted. And Tedd your condescending response caused me to lose respect for you. I'm sure the OP would have been more than thankful to receive the same response without the RTFM. I'll read any response to this, but I won't have anything more to say. This list has been polluted enough lately with nonsense. Incredible. You're entitled to your opinion as much as I am, and my opinion is that not making it clear to people that the answer to their question is plainly obvious in the manual is just as rude if not more so than suggesting they RTFM. I make a point to never just say RTFM but to also answer the question at the same time, but IMHO not telling people how fundamental their question was does not help them in the long run. At the end of the day it just encourages them to continue to rely on this list rather than learning how to find the answer themselves and to only use this list as a last resort. I make no apology for my attitude towards this type of question, and if you don't like it you can stick it where the sun don't shine. +1 I can't argue with this approach. If you're going to point the poster to the manual and *then* explain, that's the ideal way to do this. Now it could be argued that you could say, Please refer to http://php.net/manual/en/whatever.php for more info. Or you could say, RTFM. The former is more polite, but the latter will suffice. Both mean the same thing; one is simply more terse. Also stipulated that one should research a question as much as possible before posting to this list. We're not tutors; more like professional side-checkers. (Please don't take this the wrong way, newbies. You're welcome to ask questions here. Just do whatever research you can first, and follow our advice afterward, to RTFM.) Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date Comparison
At 10:01 AM +0200 9/3/09, J DeBord wrote: Telling someone RTFM is just rude and mean. And not taking the time to research your question before posting is what, thoughtful and kind? The phrase RTFM is something I don't like to tell people, and from what I remember, I have never said that to anyone. However I can understand where one could read a person's question and deduce that they did NO research for themselves. Instead, they posted their question for others to do their research for them because they were too lazy to do it themselves. No matter how you cut that, that's lame. So, I certainly don't blame anyone for telling such a person to RTFM. I would suggest that when a question asked here causes you to respond with RTFM, don't respond at all. Save yourself the time and trouble and save the person asking the question the grief of being insulted. Well that's your prerogative to do as you want. But it's a bit arrogant of you to tell others how to conduct themselves on this list, don't you think? Who made you list monitor? And Tedd your condescending response caused me to lose respect for you. No offense, but let me make this perfectly clear -- I don't give a rat's ass what you think about me. From my perspective, you could win the lottery or die tomorrow, it makes no difference to me either way. I'm not here to win/lose your respect. I'm here to help those who ask honest questions. I, like many others, simply donate our time freely without any benefit whatsoever. If you have problems with that, then you probably have bigger problems elsewhere. I'm sure the OP would have been more than thankful to receive the same response without the RTFM. I'll read any response to this, but I won't have anything more to say. This list has been polluted enough lately with nonsense. Incredible. What's Incredible is how people can post to this list thinking that they have some right to post whatever they want and expect others to comment as they want. And, if they don't get what they want, then they whine about the list being rude and mean. That's Incredible. My advice, if you have problems with this list, get over it! There's much more in this world to get upset about rather than what happens on this list. tedd --- On Sat, Aug 29, 2009 at 3:44 PM, tedd tedd.sperl...@gmail.com wrote: At 1:01 PM -0400 8/28/09, David Stoltz wrote: Hey Stuart - RTFM yourselfI did read it, and obviously misunderstood... I'm really sorry to bother you. I thought that was what a listserv like this was for - to ask questions... I'll try not to ask questions I should know the answer to next time. Whoa dude! You just received advice from a brilliant man and you are bitching about it?!? Look child, you are being told what you should do by a professional who is donating his time freely to help you. Just how did you not understand that? So, just do what he advised and say Thank you sir, may I have another? I've posted some dumb-ass questions before, but only after I took the time to research the question myself. And when someone took the time to straighten me out and help, I appreciated it. Hopefully next time you'll read the manual and take the time to understand what you read -- it would cut down on post that demonstrate just how ignorant and thankless you are at this. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Date Comparison
At 1:01 PM -0400 8/28/09, David Stoltz wrote: Hey Stuart - RTFM yourselfI did read it, and obviously misunderstood... I'm really sorry to bother you. I thought that was what a listserv like this was for - to ask questions... I'll try not to ask questions I should know the answer to next time. Whoa dude! You just received advice from a brilliant man and you are bitching about it?!? Look child, you are being told what you should do by a professional who is donating his time freely to help you. Just how did you not understand that? So, just do what he advised and say Thank you sir, may I have another? I've posted some dumb-ass questions before, but only after I took the time to research the question myself. And when someone took the time to straighten me out and help, I appreciated it. Hopefully next time you'll read the manual and take the time to understand what you read -- it would cut down on post that demonstrate just how ignorant and thankless you are at this. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date Comparison
2009/8/28 David Stoltz dsto...@shh.org: How to I ensure a variable date is not in the past, compared to the current date? Here's how I'm trying, unsuccessfully: $nextdate = 8/2/2009; if(strtotime($nextdate)=getdate()){ echo Sorry, your next evaluation date cannot be in the past, Click BACK to continue.; exit; } RTFM. The strtotime function will give you a timestamp, getdate will give you an array, so your comparison is non-sensical. Use the time function to get the current date/time as a timestamp. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date Comparison
At 10:12 AM -0400 8/28/09, David Stoltz wrote: How to I ensure a variable date is not in the past, compared to the current date? Here's how I'm trying, unsuccessfully: $nextdate = 8/2/2009; if(strtotime($nextdate)=getdate()){ echo Sorry, your next evaluation date cannot be in the past, Click BACK to continue.; exit; } David: Try to understand what strtotime() does and you'll get your answer. Function returns the number of seconds from January 1, 1970 to the date you enter. If the number of seconds are less than the current date, then the entry is past. Understand? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Date Comparison
Hey Stuart - RTFM yourselfI did read it, and obviously misunderstood... I'm really sorry to bother you. I thought that was what a listserv like this was for - to ask questions... I'll try not to ask questions I should know the answer to next time. -Original Message- From: Stuart [mailto:stut...@gmail.com] Sent: Friday, August 28, 2009 10:19 AM To: David Stoltz Cc: php-general@lists.php.net Subject: Re: [PHP] Date Comparison 2009/8/28 David Stoltz dsto...@shh.org: How to I ensure a variable date is not in the past, compared to the current date? Here's how I'm trying, unsuccessfully: $nextdate = 8/2/2009; if(strtotime($nextdate)=getdate()){ echo Sorry, your next evaluation date cannot be in the past, Click BACK to continue.; exit; } RTFM. The strtotime function will give you a timestamp, getdate will give you an array, so your comparison is non-sensical. Use the time function to get the current date/time as a timestamp. -Stuart -- http://stut.net/
Re: [PHP] Date comparison Question
On Mon, Apr 7, 2008 at 9:42 AM, [EMAIL PROTECTED] wrote: I am having a date time comparison issue. I have statically set the values here. But the data is fed from the database, CaldTime is timestamp and since it will not allow me to have 2 timestamps in the same table I set the CallEnd varchar(12). Storing the data they seem to be the same for output. I checked hexadecimal and binary to look for obscurities. $sqldata['CaldTime'] = 2008-04-07 11:15:32; $sqldata['CallEnd'] = 2008-04-07 11:17:17; $time1 = strtotime($sqldata[CaldTime]); $time2 = strtotime($sqldata[CallEnd]); $interval = $time2 - $time1; echo $interval; +++ Displays like 1.75:0 I am looking for a more precise time like 1:45 instead. Am I looking at this all wrong for time difference? hmm. different results for me w/ this code ?php $time1 = strtotime('2008-04-07 11:15:32'); $time2 = strtotime('2008-04-07 11:17:17'); echo time1: $time1 . PHP_EOL; echo time2: $time2 . PHP_EOL; $interval = $time2 - $time1; echo $interval . PHP_EOL; ? time1: 1207588532 time2: 1207588637 105 -nathan
Re: [PHP] Date comparison Question
On Mon, Apr 7, 2008 at 11:42 AM, [EMAIL PROTECTED] wrote: t the data is fed from the database, CaldTime is timestamp and since it will not allow me to have 2 timestamps in the same table ?? What database are you using? It sounds like it has a specific meaning of timestamp - probably the last time this row was modified - and you want an arbitrary date column, which would probably be a different column type. Not a string, though. An actual date type. possible names are date, datetime, datestamp... , and you I set the CallEnd varchar(12). Storing the data they seem to be the same for output. I checked hexadecimal and binary to look for obscurities. $sqldata['CaldTime'] = 2008-04-07 11:15:32; $sqldata['CallEnd'] = 2008-04-07 11:17:17; $time1 = strtotime($sqldata[CaldTime]); $time2 = strtotime($sqldata[CallEnd]); $interval = $time2 - $time1; echo $interval; +++ Displays like 1.75:0 I am looking for a more precise time like 1:45 instead. Am I looking at this all wrong for time difference? strtotime returns an integer number of seconds. The difference between $time1 and $time2 is 105. If you want minutes and seconds, you have to do the math yourself. $interval_min = floor($interval/60); $interval_sec = $interval % 60; echo $interval_min:$interval_sec; -- Mark J. Reed [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date comparison Question
Yes my mistake was looking at another record and published another. But I figured it out now i can publish 1:45 like i wanted. Having a moment there. Thank you Richard L. Buskirk On Mon, Apr 7, 2008 at 9:42 AM, [EMAIL PROTECTED] wrote: I am having a date time comparison issue. I have statically set the values here. But the data is fed from the database, CaldTime is timestamp and since it will not allow me to have 2 timestamps in the same table I set the CallEnd varchar(12). Storing the data they seem to be the same for output. I checked hexadecimal and binary to look for obscurities. $sqldata['CaldTime'] = 2008-04-07 11:15:32; $sqldata['CallEnd'] = 2008-04-07 11:17:17; $time1 = strtotime($sqldata[CaldTime]); $time2 = strtotime($sqldata[CallEnd]); $interval = $time2 - $time1; echo $interval; +++ Displays like 1.75:0 I am looking for a more precise time like 1:45 instead. Am I looking at this all wrong for time difference? hmm. different results for me w/ this code ?php $time1 = strtotime('2008-04-07 11:15:32'); $time2 = strtotime('2008-04-07 11:17:17'); echo time1: $time1 . PHP_EOL; echo time2: $time2 . PHP_EOL; $interval = $time2 - $time1; echo $interval . PHP_EOL; ? time1: 1207588532 time2: 1207588637 105 -nathan
Re: [PHP] Date comparison Question
Thank you that is exactly what i did to figure it out. Just was having a brain fart there for a minute. On Mon, Apr 7, 2008 at 11:42 AM, [EMAIL PROTECTED] wrote: t the data is fed from the database, CaldTime is timestamp and since it will not allow me to have 2 timestamps in the same table ?? What database are you using? It sounds like it has a specific meaning of timestamp - probably the last time this row was modified - and you want an arbitrary date column, which would probably be a different column type. Not a string, though. An actual date type. possible names are date, datetime, datestamp... , and you I set the CallEnd varchar(12). Storing the data they seem to be the same for output. I checked hexadecimal and binary to look for obscurities. $sqldata['CaldTime'] = 2008-04-07 11:15:32; $sqldata['CallEnd'] = 2008-04-07 11:17:17; $time1 = strtotime($sqldata[CaldTime]); $time2 = strtotime($sqldata[CallEnd]); $interval = $time2 - $time1; echo $interval; +++ Displays like 1.75:0 I am looking for a more precise time like 1:45 instead. Am I looking at this all wrong for time difference? strtotime returns an integer number of seconds. The difference between $time1 and $time2 is 105. If you want minutes and seconds, you have to do the math yourself. $interval_min = floor($interval/60); $interval_sec = $interval % 60; echo $interval_min:$interval_sec; -- Mark J. Reed [EMAIL PROTECTED] -- 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 comparison Question
On Mon, Apr 7, 2008 at 11:42 AM, [EMAIL PROTECTED] wrote: I am having a date time comparison issue. I have statically set the values here. But the data is fed from the database, CaldTime is timestamp and since it will not allow me to have 2 timestamps in the same table I set the CallEnd varchar(12). Storing the data they seem to be the same for output. I checked hexadecimal and binary to look for obscurities. $sqldata['CaldTime'] = 2008-04-07 11:15:32; $sqldata['CallEnd'] = 2008-04-07 11:17:17; $time1 = strtotime($sqldata[CaldTime]); $time2 = strtotime($sqldata[CallEnd]); $interval = $time2 - $time1; echo $interval; +++ Displays like 1.75:0 I am looking for a more precise time like 1:45 instead. Am I looking at this all wrong for time difference? Richard L. Buskirk Sorry my murloc got pawned in AV, and ever since I cant think right! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php This could be simplified to a function, but using some basic math ?php $sqldata['CaldTime'] = 2008-04-07 11:15:32; $sqldata['CallEnd'] = 2008-04-07 11:17:17; $converted = explode('.',((strtotime($sqldata['CallEnd']) - strtotime($sqldata['CaldTime'])) / 60)); $converted[1] = (($converted[1] / 6) * 3.6); echo implode(':',$converted).\n; ? -- /Daniel P. Brown Ask me about: Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo., and shared hosting starting @ $2.50/mo. Unmanaged, managed, and fully-managed! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date comparison Question
Dan I made a solution as below. $time1 = strtotime($sqldata[CaldTime]); $time2 = strtotime($sqldata[CallEnd]); $interval = $time2 - $time1; $TLength = date(i:s, strtotime(2008-01-01 01:00:$interval)); Result 01:45 Works perfect for me. Do you agree or disagree dan? On Mon, Apr 7, 2008 at 11:42 AM, [EMAIL PROTECTED] wrote: I am having a date time comparison issue. I have statically set the values here. But the data is fed from the database, CaldTime is timestamp and since it will not allow me to have 2 timestamps in the same table I set the CallEnd varchar(12). Storing the data they seem to be the same for output. I checked hexadecimal and binary to look for obscurities. $sqldata['CaldTime'] = 2008-04-07 11:15:32; $sqldata['CallEnd'] = 2008-04-07 11:17:17; $time1 = strtotime($sqldata[CaldTime]); $time2 = strtotime($sqldata[CallEnd]); $interval = $time2 - $time1; echo $interval; +++ Displays like 1.75:0 I am looking for a more precise time like 1:45 instead. Am I looking at this all wrong for time difference? Richard L. Buskirk Sorry my murloc got pawned in AV, and ever since I cant think right! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php This could be simplified to a function, but using some basic math ?php $sqldata['CaldTime'] = 2008-04-07 11:15:32; $sqldata['CallEnd'] = 2008-04-07 11:17:17; $converted = explode('.',((strtotime($sqldata['CallEnd']) - strtotime($sqldata['CaldTime'])) / 60)); $converted[1] = (($converted[1] / 6) * 3.6); echo implode(':',$converted).\n; ? -- /Daniel P. Brown Ask me about: Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo., and shared hosting starting @ $2.50/mo. Unmanaged, managed, and fully-managed! -- 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 comparison Question
On Mon, Apr 7, 2008 at 1:03 PM, [EMAIL PROTECTED] wrote: Dan I made a solution as below. $time1 = strtotime($sqldata[CaldTime]); $time2 = strtotime($sqldata[CallEnd]); $interval = $time2 - $time1; $TLength = date(i:s, strtotime(2008-01-01 01:00:$interval)); Result 01:45 Works perfect for me. Do you agree or disagree dan? There ya' go! -- /Daniel P. Brown Ask me about: Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo., and shared hosting starting @ $2.50/mo. Unmanaged, managed, and fully-managed! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Date comparison
BEOI 7308 wrote: Hi I want to substract $first_date to $second_date and print the result this way : xx days, xx hours, xx minutes i tried (strtotime($second_date)-strtotime($first_date)) but what i get is a timestamp and i dont know what to do with it Is there already a function to print the result in a human readable way ? Thx http://www.php.net/date -- Burhan Khalid phplist[at]meidomus[dot]com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] [ERR] RE: [PHP] Date comparison
Transmit Report: To: [EMAIL PROTECTED], 402 Local User Inbox Full ([EMAIL PROTECTED]) ---BeginMessage--- BEOI 7308 wrote: Hi I want to substract $first_date to $second_date and print the result this way : xx days, xx hours, xx minutes i tried (strtotime($second_date)-strtotime($first_date)) but what i get is a timestamp and i dont know what to do with it Is there already a function to print the result in a human readable way ? Thx http://www.php.net/date -- Burhan Khalid phplist[at]meidomus[dot]com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message---
Re: [PHP] Date Comparison
- Original Message - From: Dhaval Desai [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, January 11, 2003 8:38 AM Subject: [PHP] Date Comparison Well, I want to compate date is php, could anybody tell me which is the best way to do so? Look at PHPs date functions http://www.php.net/manual/en/ref.datetime.php in particular, strtotime() and then compare the timestamps. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date Comparison
On Saturday 11 January 2003 21:38, Dhaval Desai wrote: Hello ppl, Well, I want to compate date is php, could anybody tell me which is the best way to do so? I have tried various ways but nothing seems consistent. I tried for example: if(2003-1-15 2003-1-11) { echo true; } which doesn't work in some cases... Actually the above should work in all cases as you're comparing two strings constants :) In any case if your dates are in ISO format (-MM-DD) then simple comparison using , , ==, etc should always work fine. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Who cares if it doesn't do anything? It was made with our new Triple-Iso-Bifurcated-Krypton-Gate-MOS process ... */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] date comparison
I have a problem here again regarding the date comparison. I need to check the most recent date that was entered in mysql database in date format (Y-m-d), if the datetoday is a day or two days in advanced compared to the queried date. I need to make sure that the next inserted date in the mysql database whould be the next day of the last inserted date. Wow...that's confusing. :) You will probably want to look at the DATE_SUB and DATE_ADD functions in MySQL. They are in the Date and Time section of Chapter 6 in the manual. Something like this would insert the date and the day after it into two columns in the database. $date = '2002-10-31'; $r = mysql_query(INSERT INTO your_table (todaydate, tomorrowdate) VALUES ('$date','$date' + INTERVAL 1 DAY)); INTERVAL is a shortcut to the DATE_SUB and DATE_ADD functions. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date comparison
Is it too late to change the way you insert dates into the DB? I really think the unix timestamp is the easiest way to store dates... comparisons are easy, because everything is in seconds, and using date() gives you the ability to re-format your dates over and over again for presentation purposes. Just my 2 cents :) Justin on 11/11/02 4:04 PM, Michael P. Carel ([EMAIL PROTECTED]) wrote: hi to all again, I have a problem here again regarding the date comparison. I need to check the most recent date that was entered in mysql database in date format (Y-m-d), if the datetoday is a day or two days in advanced compared to the queried date. I need to make sure that the next inserted date in the mysql database whould be the next day of the last inserted date. Any idea how? Please help. Im trying to do something like this: //checking the queried date $querieddate=(2002-11-02); $incrementdate=date($querieddate),mktime(0,0,0,date(m), date(d)+1,date(Y))); $datetoday=(Y-m-d); if($incrementdate == $datetoday){ //insert $datetoday to the mysql database }else{ //insert $incrementdate to the mysql database } regards , mike Justin French Creative Director http://Indent.com.au Web Developent Graphic Design -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date comparison again
On Wed, 8 May 2002, Scott St. John wrote: Sorry to be so thick this morning, but I have a unix time stamp in my MS Sql server that is the date, plus 60 days to expire a password. I want to take today's date and compare to the two to see: 1)How many days until the password expires 2)If the password already expired then force a password change. I am missing something I am sure because I am not getting the answer I am looking for with this code: $expirePass = strtotime(now); -todays date $myPassword = (1026047985);-from the MS Sql field $itexpires = ($expirePass - $myPassword); $daysleft = intval(($mypassword - now()) / 86400)); miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date comparison again
Thank you Miguel! I was missing the /86400 and it works much better now :) On Thu, 9 May 2002, Miguel Cruz wrote: On Wed, 8 May 2002, Scott St. John wrote: Sorry to be so thick this morning, but I have a unix time stamp in my MS Sql server that is the date, plus 60 days to expire a password. I want to take today's date and compare to the two to see: 1)How many days until the password expires 2)If the password already expired then force a password change. I am missing something I am sure because I am not getting the answer I am looking for with this code: $expirePass = strtotime(now); -todays date $myPassword = (1026047985);-from the MS Sql field $itexpires = ($expirePass - $myPassword); $daysleft = intval(($mypassword - now()) / 86400)); miguel -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date comparison
You could explode it using the '-' character.. And then compare the first element to 2038.. If it's equal to our greater than, then you can compare the month, and so forth.. Rick The most beautiful thing we can experience is the mysterious. It is the source of all true art and all science. He to whom this emotion is a stranger, who can no longer pause to wonder and stand rapt in awe, is as good as dead: his eyes are closed. - Albert Einstein From: Richard Fox [EMAIL PROTECTED] Reply-To: Richard Fox [EMAIL PROTECTED] Date: Mon, 29 Apr 2002 16:29:14 -0400 To: [EMAIL PROTECTED] Subject: [PHP] date comparison I have a date string, let's call it 'date a' in the format 2020-10-16 which I want to compare to the UNIX_TIMESTAMP overflow limit (2038-01-18). Obviously I can't convert date 'a' to a timestamp because it may be too large. How can I make this comparision without converting it to a timestamp? Thanks, Rich -- 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 comparison
In my experience, it's best to keep everything is unix time stamp format -- soo easy for comparisons, and the function to convert it out to -MM-DD took me 45 seconds :) Justin French on 30/04/02 6:29 AM, Richard Fox ([EMAIL PROTECTED]) wrote: I have a date string, let's call it 'date a' in the format 2020-10-16 which I want to compare to the UNIX_TIMESTAMP overflow limit (2038-01-18). Obviously I can't convert date 'a' to a timestamp because it may be too large. How can I make this comparision without converting it to a timestamp? Thanks, Rich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] date comparison expressions
Are you retrieving the stored date from a mySQL database? If so, you can let mysql SELECT only those records that fit the tardy date criteria. -Original Message- From: ROBERT MCPEAK [mailto:[EMAIL PROTECTED]] Sent: Monday, April 01, 2002 2:22 PM To: [EMAIL PROTECTED] Subject: [PHP] date comparison expressions I'd like to compare today's date against a stored date, and then fire some code based on the result. Like. if ($today's_date stored_date+5 days) then {blah} Can somebody clue this newbie in on how to do this? -Bob -- 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 comparison
can I used the value from that variables to compare with another date value? Say another date value I will use is also retrieved from a field in table which is in Date data type as well. When you get into this stuff, it all starts getting a lot more complicated. If you want to compare two fields, make sure they're in the same format. Basically, make sure you use four digit years and two digit months and days to create your birthday fields, so they look like (for example, with today's date, 20010115 instead of 2001115 - that second one could really be anything). If you're sure you're storing the birthdays properly, you can then cut the strings up when you pull them out of the database, the first 4 chars are the year, the next two make the month (regardless of the actual month, this way it'll be "01" not "1"), then the day. Do that for both of the dates. Now, you can use the mktime() command to turn them into unix tiumestamps. $unixtimeme = mktime(myhour, myminute, mysecond, mymonth, myday, myyear); $unixtimethem = mktime(theirhour, theirminute, theirsecond, theirmonth, theirday, theiryear); Now, a unix timestamp is the number of seconds from 00:00:01, Jan 1, 1970. You can figure out the difference in seconds between the two timestamps. Divide it by (24*3600), which is the number of seconds in a day, and there you have the number of days between the dates. Incidentally, if you want to find the number of days between your birthDAYS, then you'll want to substitute in a specific year in the mktime() statements above, as you'll otherwise end up with the number of days between your exact DATES of birth. Jason -- Jason Murray [EMAIL PROTECTED] Web Design Team, Melbourne IT Fetch the comfy chair! -- 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 comparison
all right, now I have both date values in the same format (/mm/dd), say $Date1 = 20010115 and $Date2 =20010120. If what I want is to find out if $Date1 come before $Date2, can I just use this sniplet below? if ($Date1 $Date2) { ... } else { ... } Do I still need to use mktime() for this purpose? cheers Jack [EMAIL PROTECTED] "There is nothing more rewarding than reaching the goal you set for yourself" - Original Message - From: Jason Murray [EMAIL PROTECTED] To: 'Jacky@lilst' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Sunday, January 14, 2001 11:37 PM Subject: RE: [PHP] date comparison can I used the value from that variables to compare with another date value? Say another date value I will use is also retrieved from a field in table which is in Date data type as well. When you get into this stuff, it all starts getting a lot more complicated. If you want to compare two fields, make sure they're in the same format. Basically, make sure you use four digit years and two digit months and days to create your birthday fields, so they look like (for example, with today's date, 20010115 instead of 2001115 - that second one could really be anything). If you're sure you're storing the birthdays properly, you can then cut the strings up when you pull them out of the database, the first 4 chars are the year, the next two make the month (regardless of the actual month, this way it'll be "01" not "1"), then the day. Do that for both of the dates. Now, you can use the mktime() command to turn them into unix tiumestamps. $unixtimeme = mktime(myhour, myminute, mysecond, mymonth, myday, myyear); $unixtimethem = mktime(theirhour, theirminute, theirsecond, theirmonth, theirday, theiryear); Now, a unix timestamp is the number of seconds from 00:00:01, Jan 1, 1970. You can figure out the difference in seconds between the two timestamps. Divide it by (24*3600), which is the number of seconds in a day, and there you have the number of days between the dates. Incidentally, if you want to find the number of days between your birthDAYS, then you'll want to substitute in a specific year in the mktime() statements above, as you'll otherwise end up with the number of days between your exact DATES of birth. Jason -- Jason Murray [EMAIL PROTECTED] Web Design Team, Melbourne IT Fetch the comfy chair! -- 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 comparison II
may be I did not make my question clear about what I try to do. Basically if I have 2 date values in the same format like -mm-dd, can I use both values to find out if one come before another and then display message or something? Say I have $date1 = 20010115 and $date2 = 20010120 ( which of course we can easily tell that $date1 come before $date2). Can I use the sniplet below: Yep, you can use a simple conversion in that case as long as its YMD :) Jason -- Jason Murray [EMAIL PROTECTED] Web Design Team, Melbourne IT Fetch the comfy chair! -- 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]