Current location: Hot Scripts Forums » Programming Languages » PHP » changing the format of date input on form


changing the format of date input on form

Reply
  #1 (permalink)  
Old 07-20-06, 05:29 AM
Deansatch Deansatch is offline
Coding Addict
 
Join Date: Jul 2006
Location: Northumberland
Posts: 375
Thanks: 0
Thanked 0 Times in 0 Posts
changing the format of date input on form

I have wrote this code for when a form is submitted. As it stands you have to enter the date as yyyy-mm-dd. I have it so that it is output on the web page as a different format but is there a way I can let users input the date as dd-mm-yyyy or use any format?

PHP Code:

if ($action == "updategigs") {

$heading_gigs $_POST['heading_gigs'];
$gigs_title $_POST['gigs_title'];
$venue $_POST['venue'];
$date $_POST['date'];
$gigsextra $_POST['gigsextra'];


$connection mysql_connect($host,$usr,$pwd);
mysql_select_db("$db"$connection);
mysql_query("INSERT into table_gigs (date, venue) VALUES ('$date','$venue')");
mysql_query("UPDATE table_home SET gigs_title = '$gigs_title',gigsextra = '$gigsextra'
WHERE id = '0'"
);
echo 
"<script>document.location.replace('gigs.php')</script>"
__________________
Aye!
Reply With Quote
  #2 (permalink)  
Old 07-20-06, 05:38 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
You could use drop down menus, and rebuild the date after the submission for your needs. This way you can be sure the client doesn't mess it up.
Reply With Quote
  #3 (permalink)  
Old 07-20-06, 05:41 AM
Deansatch Deansatch is offline
Coding Addict
 
Join Date: Jul 2006
Location: Northumberland
Posts: 375
Thanks: 0
Thanked 0 Times in 0 Posts
I thought about doing that, but I don't know how to get the three results from the form and make them in to one to call the combined result "$date"
__________________
Aye!
Reply With Quote
  #4 (permalink)  
Old 07-20-06, 05:44 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Like this for example.
PHP Code:

$date $_POST['year'] .'-'$_POST['month'] .'-'$_POST['day']; 

But I would store the date as timestamp. This way you can search the database easier, and output the date in every format later without big changes. Do this if you want to:

PHP Code:



$date 
strtotime($_POST['year'] .'-'$_POST['month'] .'-'$_POST['day']); 
Reply With Quote
  #5 (permalink)  
Old 07-20-06, 10:54 AM
Deansatch Deansatch is offline
Coding Addict
 
Join Date: Jul 2006
Location: Northumberland
Posts: 375
Thanks: 0
Thanked 0 Times in 0 Posts
excellent once again! thanks
__________________
Aye!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
date format mysql and php Deansatch PHP 9 03-28-08 04:06 AM
Message Input Form needed!!! jreckart JavaScript 1 03-13-06 02:59 PM
search form with date search newbieasp24 ASP 1 10-17-04 02:52 PM
formmail problem gscraper Perl 12 08-27-04 03:06 AM
Problem with date and form djavet PHP 3 05-02-04 12:37 AM


All times are GMT -5. The time now is 07:22 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.