I have a problem. i want to show the current date and time in my tables of the database. I want to show it because i want to show it on my report generated in php.

By the way i do not have a "date" field in my form. Can anyone help me out?


6 Years
Discussion Span
Last Post by almostbob

You can use any of PHP functions in your scripts even if you do not have them in your forms. You need to use PHP's Date function.


//get current date
$todays_date = date('l jS \of F Y h:i:s A'); // this will show the date in this format: friday 8th of September 20 03:12:46 PM

when you create your report you add the todays_date variable to your report like this:

echo $todays_date;

FYI you can chance the PHP Date function and chance the parameters to change how the date is displayed. Check out the Date function at PHP website.


edit the table, to add a new column as a date,a nd store the timestamp, not any text representation.as php date() or mysql now()..
a text date is bigger, size matters in the opposite way
a timestamp is faster
a timestamp is easier to select date or time ranges "where date > number and date < number2"
the database is for computers, human readability is a liability, it causes errors, 10/7/11 can be 10 july 2011, 11 july 2010, 7 october 2011,
the information can be simply printed in human readble form on output, using something like cyberspatium's code sample
NOTE:not bagging prior poster;sample is accurate, even customizations to individual user regional preferences, based on this code, so that americans will see 10/7/09 and english will see 7/10/09 on the same day 7 October 2009;

it does not matter when there are ten records in the db, it begins to matter when there are ten thousand records in the db, timeout failures when there are ten million records in the db, unless you optimize the system at the start

anyhow, if you store a text date, how do you simply select between april 1 and august 15 at 3 pm last yeqar

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.