Jump to content

Date Trouble


Granny Annie

Recommended Posts

The script below references a data base with shows from 2008 and 2009. It selects the next four sequential dates to list, but ignores the year. So I have shows from 2008 included.  Suggestion?

 

<?php

  $cur = date("m/d/y");

mysql_select_db("shows", $con);

 

$s = mysql_query("SELECT * FROM live WHERE date >= '$cur' ORDER BY date LIMIT 0, 4");

 

        while($r = mysql_fetch_array($s))

        {

        echo $r['date'] . " <br> " . $r['place'] . " <br> " . $r['time'];

        echo "<br />";

echo "<br />";

 

Link to comment
https://forums.phpfreaks.com/topic/167023-date-trouble/
Share on other sites

"m/d/y"

 

Is your date field in that same format? If so, you cannot do any comparisons or sorting using that format because the fields that make it up are not ordered from MSD (most significant digit - Y) to LSD (least significant digit - d). If you want to do date comparisons or ordering by dates the format must be YYYY-MM-DD (with leading zeros), which is why the DATE data type exists.

Link to comment
https://forums.phpfreaks.com/topic/167023-date-trouble/#findComment-880641
Share on other sites

I'm way new at this and have taken over a band website after the designer skipped town. I understand what you are saying, but where do I find the date field?  Is this where I enter the show dates to begin with?  I have a pull down list for Month/Day/Year. I want shows to list with the month first, then day, then year.  I'll try to find the code and copy it into a message.

Link to comment
https://forums.phpfreaks.com/topic/167023-date-trouble/#findComment-881454
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.