Jump to content

Formating Date Output from sql


limecity

Recommended Posts

I made a php form which enable the user to select a date and submit, it will enter the database with this code:

 

 

$_POST['indate'] = date("Y",time())."-".$_POST['ciMM']."-".$_POST['ciDD'];

$_POST['outdate'] = date("Y",time())."-".$_POST['coMM']."-".$_POST['coDD'];

 

 

I also manage to output the date with this coding

 

<?php

        while ($row = mysql_fetch_array($result))

        {

        echo'<tr><td>' '</td><td>'.$row['indate'].'</td><td>'.$row['outdate'].'</td><td> </td></tr>';

          }

?>

 

but the output became this "2007-09-06" format.

 

PROBLEM

How do i output it to be like 2007-September-06 ?

 

 

 

 

Link to comment
Share on other sites

you could save yourself some time by simply storing the times plainly (without all your formatting) like, just a timestamp... but then PULL IT OUT with the formatting.

 

You would pull from your mysql table with:

 

SELECT DATE_FORMAT('date_column','%Y-%M-%d') AS date.....

Link to comment
Share on other sites

oh. thanks for the reply.

okay, i might try diff approach.

 

my form is a plain html

with two drop down bar [day] [month] for the user selection

 

as you see here

$_POST['indate'] = date("Y",time())."-".$_POST['ciMM']."-".$_POST['ciDD'];

$_POST['outdate'] = date("Y",time())."-".$_POST['coMM']."-".$_POST['coDD'];

 

ciMM is the variable for Month

ciDD is the varibale for Date

 

------------------

 

as you suggested,

 

how do i insert those data into the database as plain format and pull it out with formating inside the table created on the page?

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.