I am looking at creating a form that when submitted, posts a date and time (though time not important) stamp to the MySQL field entry.
If the Date is within the current date (ie. Closed Date set to 11/12/08 - viewing on 12/11/08 would display it, but viewing on 12/12/08 would not show it) then it would display, otherwise it would now.
I can find many auto entry scripts for adding a date, but not idea how to get PHP to see it, and say "aahh, that date has passed, I won't show it". Or "yes, that's in the future, I'll display that".
I've seen it done in ASP.net, but haven't any idea how to code that, so cannot decipher to use here.
Any help would be appreciated.
Simon
Time/Date Stamp SQL Entry via PHP. Remove when Time's up!
Moderator: General Moderators
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Time/Date Stamp SQL Entry via PHP. Remove when Time's up!
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Time/Date Stamp SQL Entry via PHP. Remove when Time's up!
Code: Select all
SELECT * FROM `table` WHERE DATE(`post_date`) >= CURDATE()- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: Time/Date Stamp SQL Entry via PHP. Remove when Time's up!
First of all you'll have to create two table fields in your database
1. strDate - datatype= DATE
2. strTime = datatype= TIME
It's important that you set the correct datatypes for every field.
In order to create date and time variables you can do the following:
For further info on date and time take a look at http://uk2.php.net/date
1. strDate - datatype= DATE
2. strTime = datatype= TIME
It's important that you set the correct datatypes for every field.
In order to create date and time variables you can do the following:
Code: Select all
$thisDate=date("Y-m-d"); //this sets $strDate to the current date formatted like: YYYY-MM-DD (this is how a MySQL database will store it)
$thisTime=date("H:i:s"); //this sets $strTime to the current time formatted like: HH:MM:SS (this is how a MySQL database will store it)