Forum
Storing value of Date Field in DB
I'm trying to store the value of a 'Date' field in the Database.
I need to be able to test to see if the date stored is in the past or not.
So far, I've tried storing it in a column that's a DATE column, or a VARCHAR column - neither receive any data (presumably not formatted the way the columns are expecting).
so this is how perch stores the date info in the database
you should store your dates as Y-m-d H:i:s as this would be consistent with how perch stores the same information.
If you use a date template tag we will store the value correctly for you. What are you trying to achieve outside of Perch functionality?
If you can explain what the task is you need to do and include code and your Diagnostics Report as requested on the thread creation page, we'll be in a better position to help.
Hi Robert,
I'm using the Perch Form API class, which I think might be making this difficult.
Here is my code for the datepicker field:
The column 'dateDate' is
datetime NOT NULL DEFAULT '2013-01-01
.At the moment, it's still not storing the value in the DB - any ideas?
Thanks!
Are you using a template? If not and you're hardcoding your fields, you'll need to make sure you receive the date field: