wrathican Posted June 26, 2007 Share Posted June 26, 2007 hey, ive never used the date function before and now i need to know how to get it and format it to insert into a mysql databse and also get it from a mysql database and format it for being echoed. i know how to pull stuff from DB's and insert them no problems but im just stuck with this. any help? Quote Link to comment Share on other sites More sharing options...
Wildbug Posted June 26, 2007 Share Posted June 26, 2007 Look it up in the PHP manual, then look up the DATE type in MySQL (or whatever db) and the DATE_FORMAT function in the same. Quote Link to comment Share on other sites More sharing options...
Caesar Posted June 26, 2007 Share Posted June 26, 2007 Store the date as a timestamp and then format it any way you want when you want to display it. <?php //Current timestamp - Ready to be inserted into your db. $mydate = time(); //Takes timestamp and formats it to display as: June 26, 2007 $showdate = date("M d, Y", $mydate); ?> Quote Link to comment Share on other sites More sharing options...
cluce Posted June 26, 2007 Share Posted June 26, 2007 here is an example snippets from my site that may help you.. this stores the date/time in database $sql2 = "UPDATE employees SET last_login=NOW() WHERE username = '$checkuser' LIMIT 1"; this will select date time from table for display on web page in standard time $last_login = ("SELECT DATE_FORMAT(last_login, '%b %e %Y at %r') aS last_login FROM employees WHERE username = '$checkuser' LIMIT 1"); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.