You are here: Re: Second Saturday? « All PHP « IT news, forums, messages
Re: Second Saturday?

Posted by kenrbnsn on 07/03/06 06:52

-Lost wrote:
> "kenrbnsn" <kenrbnsn@gmail.com> wrote in message
> news:1151816630.872688.71210@75g2000cwc.googlegroups.com...
>
> <?php
> > $today = time();
> > $sec_sat = (strtotime('2nd saturday this month') >
> > $today)?strtotime('2nd saturday this month'):strtotime('2nd saturday
> > next month');
> > echo date('l, F j, Y',$sec_sat);
> > ?>
>
> What are you testing on? My setup gives me July 15th with that code.

This is weird. When I tested it, before I posted the answer came out
correct. Yet, when I tested it again after reading your response, I,
too, got July 15th. :-(

I know that the strtotime() function has been known to have problems
with relative dates like next, last, 1st, 2nd, etc.

Here is my second code snippet. I left in my debugging code...
<?php
$dts = array();
$dts['today']['ts'] = (isset($_GET['d']))?strtotime($_GET['d']):time();
$dts['1st saturday']['ts'] = strtotime('1st saturday');
$dts['next saturday']['ts'] = strtotime('next saturday');
$dts['this saturday']['ts'] = strtotime('this saturday');
$dts['2nd saturday next month']['ts'] = strtotime('2nd saturday next
month');
foreach($dts as $k => $v) {
// echo $k . '<br>' . $v . '<br>';
$dts[$k]['dt'] = date('l, F j, Y',$dts[$k]['ts']); }
echo '<pre>' . print_r($dts,true) . '</pre>';
$sec_sat = ($dts['1st saturday']['ts'] > $dts['today']['ts'])?$dts['1st
saturday']['ts']:$dts['2nd saturday next month']['ts'];
echo date('l, F j, Y',$sec_sat);
?>

Ken

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация