Results 1 to 3 of 3

Thread: MySQL date & time function.

  1. #1
    Join Date
    Jan 2009
    Posts
    74

    MySQL date & time function.

    Hi,

    I am new with PHP & MySQL.

    The problem I am confused with is the MySQL date & time function.

    I am really confused with these functions for their use & how to query the database in various ways?

  2. #2
    Join Date
    May 2008
    Posts
    29

    Re: MySQL date & time function.

    Date and Time Functions

    To know the list of date & time functions available in MySQL please go to this webpage.
    http://dev.mysql.com/doc/refman/5.1/...functions.html
    It will let you know & understand the various date & time functions their use & importance.

  3. #3
    Join Date
    Jan 2009
    Posts
    66

    Re: MySQL date & time function.

    The default way to store a date in MySQL is with the type DATE
    Format which is standard:
    • YYYY-MM-DD
    • Date Range: 1000-01-01 to 9999-12-31


    To insert the current date into your table you can use MySQL's built-in function CURDATE() in your query. One is manual & second is using CURDATE()

    PHP Code:
    <?php
    //This assumes you have already created the 'dateplayground' table
    //Connect to DB
    $query_manual "INSERT INTO dateplayground (dp_name, dp_date)
        VALUES ('DATE: Manual Date', '2020-2-14')"
    ;
    $query_auto "INSERT INTO dateplayground (dp_name, dp_date)
        VALUE ('DATE: Auto CURDATE()', CURDATE() )"
    ;

    mysql_query($query_manual) or die(mysql_error());
    mysql_query($query_auto) or die(mysql_error());
    ?>
    For detail information please follow this tutorial: http://www.tizag.com/mysqlTutorial/mysql-date.php

Similar Threads

  1. Replies: 2
    Last Post: 29-11-2011, 09:29 AM
  2. Strings function in MySQL
    By Dino M in forum Software Development
    Replies: 6
    Last Post: 09-12-2010, 04:01 AM
  3. Discussion of Date and Time function
    By Gerri in forum Software Development
    Replies: 3
    Last Post: 29-01-2010, 12:03 PM
  4. Replies: 3
    Last Post: 07-11-2009, 09:36 PM
  5. Replies: 2
    Last Post: 10-04-2009, 09:36 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,009,919.15184 seconds with 16 queries