vBulletin date/time function (PHP/MySQL)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MyPornLife.info
    New Member
    • Apr 2009
    • 28
    • 3.8.x

    vBulletin date/time function (PHP/MySQL)

    Hello
    Im trying to create something for my vBulletin forum. & i need to know how vBulletin time/date function work

    as far as i know, it takes time from server

    there's a date-time on every post like this : Mon 11th May '09, 2:29pm
    for such thing, what kind of MySQL Table i need to use? DATE, DATETIME, TIMESTAMP, TIME, VARCHAR....etc ????

    & what will be the command ?? suppose the field name is added_time
    mysql_query("INSERT INTO `TABLE_NAME` (added_time) VALUES('??????????')");

    yes i want this ???????? value.

    & what will be the retrieve code...when i need to show this on a page

    & there must be TIMEZONE thing...means, it should vary user to user according to their vBulletin TimeZone setup.


    somebody plz help me
  • Floris
    Senior Member
    • Dec 2001
    • 37767

    #2
    vbdate (line 3462)
    Formats a UNIX timestamp into a human-readable string according to vBulletin prefs

    Note: Ifvbdate() is called with a date format other than than one in $vbulletin->options[], set $locale to false unless you dynamically set the date() and strftime() formats in the vbdate() call.

    return: Formatted date string
    string vbdate (string $format, [integer $timestamp = TIMENOW], [boolean $doyestoday = false], [boolean $locale = true], [boolean $adjust = true], [boolean $gmdate = false], [array $userinfo = ''])
    string $format: Date format string (same syntax as PHP's date() function)
    integer $timestamp: Unix time stamp
    boolean $doyestoday: If true, attempt to show strings like "Yesterday, 12pm" instead of full date string
    boolean $locale: If true, and user has a language locale, use strftime() to generate language specific dates
    boolean $adjust: If true, don't adjust time to user's adjusted time .. (think gmdate instead of date!)
    boolean $gmdate: If true, uses gmstrftime() and gmdate() instead of strftime() and date()
    array $userinfo: If set, use specified info instead of $vbulletin->userinfo

    Comment

    • MyPornLife.info
      New Member
      • Apr 2009
      • 28
      • 3.8.x

      #3
      wow very fast reply
      well im trying to understand it as im not an advance coder of php/mysql

      i'll let u know the result

      Comment

      • MyPornLife.info
        New Member
        • Apr 2009
        • 28
        • 3.8.x

        #4
        ok as i said im not expert....im facing problem

        i used this & got error
        vbdate(string $format, [integer $timestamp = TIMENOW], [boolean $doyestoday = false], [boolean $locale = true], [boolean $adjust = true], [boolean $gmdate = false], [array $userinfo = '']);

        use this & got this result: 02-06-2009
        vbdate($format=date('d-m-Y'), $timestamp=TIMENOW, $doyestoday=false, $locale=false, $adjust=false, $gmdate=false);

        well i use this & the result is: 06-02-2009, 05:31 PM (ya it shows good result)
        vbdate($vbulletin->options['dateformat'] . ', ' . $vbulletin->options['timeformat']);

        so if i use the above commad..it will store directly 06-02-2009, 05:31 PM in MySQL table
        so when a user open a page (which uses that time) will see 06-02-2009, 05:31 PM his timezone will not effect

        so plz tell me how can i use time zone

        well my point is...I can retrieve current time & store that on MySQL table (on a VARCHAR or TEXT field) but that will be a fixed value & other user will see that fixed value...but i want TIMEZONE thing...so the date/time will vary

        u said to use timestamp type field...but i think it'll not store the value: 06-02-2009, 05:31 PM directly...will it ???

        tnx in advance
        Last edited by MyPornLife.info; Tue 2 Jun '09, 9:45am.

        Comment

        • MyPornLife.info
          New Member
          • Apr 2009
          • 28
          • 3.8.x

          #5
          ^^^^^^

          hay maybe im wrong...i've just found that....I dont need to put any value in TIMESTAMP field...its upgrading autometically with current time when other fields are putted some value

          so user's TIMEZONE autometically work with that or i need to put some code to retrieve TIME/DATE according to user's timezone ???

          Comment

          • Steve Machol
            Former Customer Support Manager
            • Jul 2000
            • 154488

            #6
            You use the Unix Timestamp. You can use this online tool to convert dates and times to Unix Timestamps:



            Just remember to enter in the values for the server and not the date and time in the user's specific timezone. vB will convert as needed.
            Steve Machol, former vBulletin Customer Support Manager (and NOT retired!)
            Change CKEditor Colors to Match Style (for 4.1.4 and above)

            Steve Machol Photography


            Mankind is the only creature smart enough to know its own history, and dumb enough to ignore it.


            Comment

            • MyPornLife.info
              New Member
              • Apr 2009
              • 28
              • 3.8.x

              #7
              im really confussed as I found that vB store it's post/thread's date-time info in dateline field which is INT type. I understand that the value is a unix timestamp.
              but there's my point...how does vB convert Tue, 02 Jun 2009 15:46:08 GMT (normal date-time) into 1243957568 (unix timestamp)....whats the command ??
              Steve Machol..i think vB doesn't use that 3rd party site to convert...does it ??

              & later what is the command that convert timestamp to normal time-date for a specific post/thread (to show in a page & TIMEZONE effect is must). I saw that $post[postdate] & $post[posttime] are using in postbit to show that post's posted time.

              Comment

              • Steve Machol
                Former Customer Support Manager
                • Jul 2000
                • 154488

                #8
                I'm sure there is code in vB that does that. I do not know what that code is though. Did you try checking over at www.vbulletin.org?
                Steve Machol, former vBulletin Customer Support Manager (and NOT retired!)
                Change CKEditor Colors to Match Style (for 4.1.4 and above)

                Steve Machol Photography


                Mankind is the only creature smart enough to know its own history, and dumb enough to ignore it.


                Comment

                • MyPornLife.info
                  New Member
                  • Apr 2009
                  • 28
                  • 3.8.x

                  #9
                  not yet...

                  but i've found half of it.
                  the current GMT time can be found by the PHP command: time();
                  it'll give u something like this 1243990265 ....the unix timestamp

                  u can easily store it at MySQL data base (time or INT type field)

                  u can read this value from DB anytime & get the posted time.

                  but still it'll give u the unix timestamp
                  here's im still looking for....what php code convert that into normal date-time & must use user's TimeZone thing

                  Comment

                  Related Topics

                  Collapse

                  Working...