Jump to content

dates in php & mysql


careym1989

Recommended Posts

Hey all, again! I'm not familiar with the date stuff in MySQL and PHP, so I figured I'd post it here to learn. Help would be much obliged.

 

I had a couple of questions, but I'll start with the scenario. I'm developing an application for the web to list events that has the option of "RSVP" under the Options section (see: http://www.cmsecho.com/events_Upd.php). RSVP is a different page and it uses $_GET to get the event title, time, and date. Then a form is created that asks you to enter your name, email, phone, and the number of guests.

 

I want to take the static date of the event (not a timestamp) and insert it into my MySQL database so that when the admin goes to the password-protected page to view RSVPs for all events, they can sort by event date and view that specific event's RSVPs. Does this make sense? Optimal output of the date on the list of RSVP's would be: November 15, 2008.

 

Sorry if I'm not coherently spelling out my problem. I'll be glad to clarify any questions & any help would be appreciated.

 

-Carey

Link to comment
https://forums.phpfreaks.com/topic/132907-dates-in-php-mysql/
Share on other sites

$date = $_GET['eventDate'];
$timeStamp = strtotime($date);
$mysqlDate = date('Y-m-d', $timeStamp);

$mysqlDate can be used in a DATE-type column.

 

to show the date from the DB:

$dateFromDB = //get the date however
$timeStamp = strtotime($dateFromDB);
$displayDate = date('F d, Y', $timeStamp);

Link to comment
https://forums.phpfreaks.com/topic/132907-dates-in-php-mysql/#findComment-691162
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.