String to mysql date field

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Noyb

    String to mysql date field

    How do I convert a string into a value I can upload to mysql date field.
    Specifically, I have a user select a month, day and year from
    drop-downs, then I want them submitted to one date field. Thanks!
    Steve.
  • Jeff Rodriguez

    #2
    Re: String to mysql date field

    Noyb wrote:
    [color=blue]
    > How do I convert a string into a value I can upload to mysql date field.
    > Specifically, I have a user select a month, day and year from
    > drop-downs, then I want them submitted to one date field. Thanks!
    > Steve.[/color]

    You want to convert a string to a unix timestamp, then you can use the functions
    in mysql to convert the timestamp to mysql native.

    Parse about any English textual datetime description into a Unix timestamp


    Also, use Mishoo's dHTML calendar: http://sourceforge.net/projects/jscalendar/

    Comment

    • Geoff Berrow

      #3
      Re: String to mysql date field

      I noticed that Message-ID: <4Igpc.26291$5a .24525@okepread 03> from Jeff
      Rodriguez contained the following:
      [color=blue][color=green]
      >> How do I convert a string into a value I can upload to mysql date field.
      >> Specifically, I have a user select a month, day and year from
      >> drop-downs, then I want them submitted to one date field. Thanks!
      >> Steve.[/color]
      >
      >You want to convert a string to a unix timestamp, then you can use the functions
      >in mysql to convert the timestamp to mysql native.[/color]

      Why, when he can arrange the dropdown boxes to provide a suitable date?
      Say the boxes return year month and day

      function make_mysql_date ($y,$m,$d){
      $array = array($y,$m,$d) ;
      $mysql_date = implode("/", $array);
      return $mysql_date;
      }

      Not that I usually bother with MySql's date format these days. Mostly I
      simply store a Unix timestamp.
      --
      Geoff Berrow (put thecat out to email)
      It's only Usenet, no one dies.
      My opinions, not the committee's, mine.
      Simple RFDs http://www.ckdog.co.uk/rfdmaker/

      Comment

      • Gordon Burditt

        #4
        Re: String to mysql date field

        >> How do I convert a string into a value I can upload to mysql date field.[color=blue][color=green]
        >> Specifically, I have a user select a month, day and year from
        >> drop-downs, then I want them submitted to one date field. Thanks!
        >> Steve.[/color]
        >
        >You want to convert a string to a unix timestamp, then you can use the
        >functions
        >in mysql to convert the timestamp to mysql native.[/color]

        This doesn't work very well for some applications. It's problematical
        for anything dealing with a date of birth of a living person, and
        even more problematical for genealogy. (Some implementation treat
        a UNIX time_t as signed, yielding a time range of about 1901-2038,
        which is too small. Even worse is the ones that interpret it as
        unsigned, giving a time range of about 1970-2106, which is really
        bad if your application deals with people receiving retirement
        benefits).

        Even the MySQL native date format has problems if you can trace
        your ancestors back more than about 2,004 years.

        Gordon L. Burditt

        Comment

        Working...