Mysql help needed.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • acctman
    Confirmed User
    • Oct 2003
    • 2840

    #1

    Mysql help needed.

    i have a db field called p_time and all the entires are in unix_timestamp 1109679576 how do i convert all field entries to a format like this 8/23/2005 0:08?

    this is all i've found so far
    $rs=mysql_fetch_row(mysql_query("select p_time from rate_forum_posts"));
    echo date("m/d/YYYY h:i ", $rs[0]);

    that doesn't work when i try an to run it on the insert SQL page
  • woj
    <&(©¿©)&>
    • Jul 2002
    • 47882

    #2
    use -> FROM_UNIXTIME()
    Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
    Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
    Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager

    Comment

    • acctman
      Confirmed User
      • Oct 2003
      • 2840

      #3
      do you have a working example that i can work from, to put something together to run at shell?

      Comment

      • Mr. Mike
        Confirmed User
        • Aug 2004
        • 913

        #4
        From_unixtime()
        Sig for sale. ICQ: 163-545-054

        Comment

        • mlj
          Registered User
          • Jun 2005
          • 89

          #5
          http://dev.mysql.com/doc/mysql/en/da...functions.html

          Comment

          • Brujah
            Beer Money Baron
            • Jan 2001
            • 22157

            #6
            SELECT from_unixtime(p_time) FROM rate_forum_posts

            Comment

            • acctman
              Confirmed User
              • Oct 2003
              • 2840

              #7
              Originally posted by Brujah
              SELECT from_unixtime(p_time) FROM rate_forum_posts
              it's not giving the right format that i need 8/23/2005 0:08

              Comment

              • mrthumbs
                salad tossing sig guy
                • Apr 2002
                • 11702

                #8
                why would you want to do that?

                Comment

                • mrthumbs
                  salad tossing sig guy
                  • Apr 2002
                  • 11702

                  #9
                  date("m/d/Y H:i" should put it in the right format..

                  YYYY gives 2005200520052005 as output. and mind the cap H...

                  Make sure you converted the dbase field to Varchar since INT (which is probably used to store the numeric format) doesnt support the format (which includes spaces and characters) you want.

                  Comment

                  • Brujah
                    Beer Money Baron
                    • Jan 2001
                    • 22157

                    #10
                    Originally posted by acctman
                    it's not giving the right format that i need 8/23/2005 0:08
                    SELECT date_format(from_unixtime(p_time),'%m/%d/%Y %H:%i') FROM rate_forum_posts

                    Comment

                    • acctman
                      Confirmed User
                      • Oct 2003
                      • 2840

                      #11
                      i'm migrating a forum over and the new forum has the date field in the format of 8/23/2005 0:08

                      Comment

                      • acctman
                        Confirmed User
                        • Oct 2003
                        • 2840

                        #12
                        Originally posted by Brujah
                        SELECT date_format(from_unixtime(p_time),'%m/%d/%Y %H:%i') FROM rate_forum_posts
                        THANK YOU!... i'd hug you if i could =)

                        Comment

                        Working...