Date data type and manipulation for add and edit through mysql & php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dkyadav80
    New Member
    • Jul 2008
    • 21

    Date data type and manipulation for add and edit through mysql & php

    Hi guys,

    I have a form in html , all description below:
    first: name of persion (input type box)
    second: job profile (input type box)
    third: experience from: list box (Month : Jan, Feb,.. format) and
    experience to: list box (year: 2008,2007,2006, ...)

    In Mysql database only 4 filed,
    1. Name(data type - varchar),
    2. Profile(data type - varchar)
    3. Experience From, (data type - Date)
    4. Experience To :(data type - Date)

    I want to store date only month and year month should be first three letter in txt is mondatry (like Jan, Feb,) Means copmlete date format should be like this Jan 2008.

    What shold data type and how we manipulate(inse rt and edit ) ony month year throw php and mysql . The Fom and To field should be date data type mondatory.

    pls help me. I'm stuck.
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Try to concatinate the strings and convert to date format before insert into DB.

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      Better store the complete date and you can fetch only the month and year part later on as per your requirments.

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Just use the normal order specified to store the date. The front end should be the one responsible for formatting the date according to the user's preferences.

        Comment

        • pbmods
          Recognized Expert Expert
          • Apr 2007
          • 5821

          #5
          Heya, dkyadav.

          Check out PHP's date() (http://php.net/date) and strtotime() (http://php.net/strtotime) functions.

          Comment

          • pbmods
            Recognized Expert Expert
            • Apr 2007
            • 5821

            #6
            Heya, dkyadav80.

            You've been warned about double-posting, and yet you keep doing it.

            Your account is now banned for 1 week.

            Continued violation of the site Posting Guidelines will result in a PERMANENT ban on your account.

            If you have any questions or concerns, feel free to contact me anytime.

            Thanks for your time.

            pbmods

            Comment

            • cjjer
              New Member
              • Aug 2008
              • 4

              #7
              you can use date_format format the datetime string:
              select date_format(now (), %w %m %y);

              Comment

              Working...