Results 1 to 4 of 4

Thread: Saving date in mysql db

  1. #1
    Join Date
    Nov 2007
    Posts
    151
    Thanks
    67
    Thanked 0 Times in 0 Posts

    Default Saving date in mysql db

    Hi,

    I have a form which includes text field.
    I want to enter there a date like: 22/05/2014 (something like: date("d.m.Y",$x);)
    and the information will be saved in a mysql database.

    I don't know how to do it correctly since all the time the db returns be the date 31.12.1969

    I'll appreciate your help!

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    You should be using timestamps because they're a more accurate way to store dates. What's happening here is that you're actually already using timestamps somehow, and your (invalid timestap) input is being converted to the first possible date in timestamps, which is the end of 1969-- timestamps start in 1970, because dates before then are rarely relevant to computers.

    What format do you want to use? If not timestamps, why not?
    Are all parts of your system configured for that type of format?
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Nov 2007
    Posts
    151
    Thanks
    67
    Thanked 0 Times in 0 Posts

    Default

    I want to write a date in the future and I don't know how to convert it into timestamp

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Do you want to use timestamps? Is your database configured for timestamps? Is the rest of the script configured for that?

    I'm still not sure exactly what the problem is.

    Are you looking for a way to create a timestamp? The answer is probably the strtotime() function:
    http://www.php.net/manual/en/function.strtotime.php
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Similar Threads

  1. passing & recieving a date with mysql using Jason's Date Input Calendar
    By kkslider in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 02-19-2012, 03:30 PM
  2. Saving XML file to Mysql Database
    By newphpcoder in forum MySQL and other databases
    Replies: 0
    Last Post: 10-18-2011, 09:22 AM
  3. Saving to mySQL and XML in PHP
    By Tissy in forum PHP
    Replies: 1
    Last Post: 10-01-2011, 01:52 AM
  4. How to pass a date to mysql using Jason's Date Input Calendar
    By duckofprey in forum Dynamic Drive scripts help
    Replies: 11
    Last Post: 04-04-2009, 07:00 PM
  5. php date to mysql date
    By city_coder in forum PHP
    Replies: 0
    Last Post: 08-16-2008, 01:05 PM

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
  •