This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Dreamweaver > April 2004 > PHP/MySQL date insert from dropdowns





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author PHP/MySQL date insert from dropdowns
wozza

2004-04-08, 7:28 am

Hi

I'm completely new to PHP (normally we use ASP) but I need to create a
mini content management system which includes a requirement to upload
files and the only way I can go is PHP upload because of ISP
restrictions. And I only have a couple of days to get this working.

Anyway, part of the requirement is to allow start and end date input
for promotions. I want to do these as separate dropdowns for day,
month & year to avoid incorrect formatting etc. by the user. My
question is how do I merge these fields into a mysql compatible date
before inserting them into the record?

Any help would be appreciated. Thanks.

Warren
Joaquim Lopes

2004-04-08, 5:30 pm

You can use
[b]mktime(0, 0, 0, $month, $day, $year);[/b] which returns an Unix timestamp.
[b]date("M-d-Y", mktime(0, 0, 0, $month, $day, $year));[/b] which returns a
string formatted according to the given format string using the given integer
timestamp.
[b]$date = sprintf("%04d-%02d-%%02d", $year, $month, $day);[/b]

Hope this helps.

Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews