Wrox Programmer Forums
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 28th, 2004, 11:20 PM
Authorized User
 
Join Date: Nov 2003
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Entering dates.

Hello,
Im not sure wheter this question should of gone under Mysql.

When i enter a date from my PHP page into mysql i have to use the format YYYY-MM-DD. Is there a setting to change this format as i would like to be able to enter DD-MM-YYYY

Thanks
Chris

 
Old January 29th, 2004, 07:24 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No. MySQL date fields are a fixed format. You can manipulate the date info you get back from MySQL and display it however you want.

// We convert the MySQL date into a unix timestamp in the query:

$query = "SELECT UNIX_TIMESTAMP(date_column), ... AS date FROM table";
$result = mysql_query($query);

if (FALSE !== $result)
{
    while ($row = mysql_fetch_array($result))
    {
        // And format that unix timestamp into a DD-MM-YYYY string
        // for outputting.

        echo "Your date is " . date("d-m-Y", $row['date']) . ".\n";
    }
}

for more info, look at:
  http://www.mysql.com/doc/en/Date_and...functions.html
  http://www.php.net/date


Take care,

Nik
http://www.bigaction.org/





Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA code for entering the same data for dates rohit_ghosh Access VBA 1 May 3rd, 2007 09:45 AM
Entering special characters on the form MyronCope Classic ASP Basics 1 November 21st, 2006 09:27 AM
Entering a password, then "enter" from keyboard? natalie09 Javascript How-To 2 April 22nd, 2004 02:56 PM
entering data Kelly Johnson Classic ASP Databases 1 August 7th, 2003 07:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.