Web Hosting Talk







View Full Version : timestamps, DBs, and PHP, O my!


Gamenati
05-07-2003, 06:18 AM
Howdy,

I'm making a simple poll script, and i need to display the poll of todays date, so i threw a time() into the colom "date"
now, how would i display the poll of todays date?

something like:

$query = "SELECT pollid, date FROM poll WHERE date = ?" ;

thanks in advance

Rich2k
05-07-2003, 06:45 AM
If the date column is only yyyy-mm-dd then you could try

SELECT pollid, date FROM poll WHERE date = NOW()

wakkow
05-07-2003, 02:28 PM
As Rich2k mentioned, it all depends how the date is stored.. Did you build a datestamp in PHP first? Use the mysql datestamp? I don't have the specifics, but you either need to build it into the query (if you're using mysql's datestamping abilities) or build a datestamp for today (if using php's)

Gamenati
05-07-2003, 03:18 PM
i just used time()
which includes the seconds and minutes

Gamenati
05-07-2003, 03:39 PM
someone

X-Istence
05-08-2003, 03:49 AM
time() = seconds since the unix epoch, it woulda been easier if you used date() in conjunction with time so that you could just put the date in the date collumn.

Gamenati
05-08-2003, 03:29 PM
like date(time())?