Re: How to loop through the dates? [message #186128 is a reply to message #186117] |
Sun, 15 June 2014 19:30 |
Tim Streater
Messages: 328 Registered: September 2010
Karma:
|
Senior Member |
|
|
In article <ywx2wjj7uwar$(dot)105qt7ftnicew$(dot)dlg(at)40tude(dot)net>, richard
<noreply(at)example(dot)com> wrote:
> http://mroldies.net/radio/tracker2.php
>
>
> I've got my report generator almost completed.
> I only need to know how I can loop through the dates.
You haven't told us what the problem is you are experiencing.
> print $master[$i]['date'];
but from this I deduce that the dates are not coming out in the order
you expect (it's irritating to have to deduce what problem people are
experiencing. Cats, dogs, horses, etc, we forgive, because they can't
speak. You, OTOH, can. So please state, in future, what the problem is
and give *examples* of incorrect output).
My advice is not to store dates as strings (or even for whatever data
type mysql uses), but as integers, and use the number of seconds since
the epoch. You can use strtotime() to convert dates/times to a number
of seconds.
Then the sort will work properly.
Then for output,
echo date ('M jS, Y', $value);
will output the date in a suitable format.
--
"If you're not able to ask questions and deal with the answers without feeling
that someone has called your intelligence or competence into question, don't
ask questions on Usenet where the answers won't be carefully tailored to avoid
tripping your hair-trigger insecurities." - D M Procida, UCSM
|
|
|