Announcement

Collapse
No announcement yet.

How to format tiemstamp in template

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to format tiemstamp in template

    Like in the title. How to format time stamp in template syntax.

    I try

    {vb:time timestamp} but it displays "2:00" all the time
    {vb:time timestamp, His} this don't even go through parser
    {vb:time His} this displays "His" all the time

    After your documentation:

    date
    {vb:date timestamp[, format]}
    Formats a UNIX timestamp using the default date format for the active language. A format may also be explicitly specified. Timezone will be corrected for the viewing user.
    time
    {vb:time timestamp[, format]}
    As above, though uses the default time format instead of date format.
    So which string formatting standard does it follows if any? Maybe ISO 8601?

  • #2
    Try this:

    Code:
    {vb:date timestamp, 'H:i:s'}

    GIPHY for vB5 AutoLinker Auto-Create Flag Report INITIALS AVATAR (Better) Name Card Quote Selected Text Likes Summary Disable AJAX Pagination Stop Links in Posts...& MORE!

    Comment


    • #3
      Couldn't you just place it in documentation?

      Any way it does not work.

      This code in template:

      Code:
      <link rel="stylesheet" type="text/css" href="{vb:raw baseurl}/css/background.css?{vb:date timestamp, 'H:i:s'}">
      gives me this in output:

      Code:
      <link rel="stylesheet" type="text/css" href="[URL="http://www.vbulletin.com/forum/core/view-source:http://ibeauty.pl/forum/css/background.css?H:i:s"]http://xxx.xx/forum/css/background.css?H:i:s[/URL]">

      Comment


      • #4
        It works for me. But why are you appending timestamp to CSS URL? Doing so will slow down your page as the CSS file will not be cached. Why not just append the vB version?

        Code:
        <link rel="stylesheet" type="text/css" href="{vb:raw baseurl}/css/background.css?v=[COLOR=#FF0000]{vb:var vboptions.simpleversion}[/COLOR]" />
        For version 5.1.4, this will output.

        Code:
        <link rel="stylesheet" type="text/css" href="{vb:raw baseurl}/css/background.css?v=[COLOR=#FF0000]514[/COLOR]" />

        GIPHY for vB5 AutoLinker Auto-Create Flag Report INITIALS AVATAR (Better) Name Card Quote Selected Text Likes Summary Disable AJAX Pagination Stop Links in Posts...& MORE!

        Comment


        • #5
          Because this css changes sometimes. And there is some bug in vB that i cannot change header template directly. I have to revert header template then I can modify it. It is annoying as hell, so I decide to download one more file.

          So why does 'H:i:s' don't work for me?

          Comment


          • #6
            There is no bug with the header template, it is able to be edited fine.
            MARK.B | vBULLETIN SUPPORT

            TalkNewsUK - My vBulletin 5.7.1 Demo
            AdminAmmo - My Cloud Demo

            Comment


            • #7
              If you want to add a new css file, you don't have to edit the header template. You can add a template hook (Products & Hooks > Manage Hooks > Add New Hook) and select header_head Hook Location and then create a new template that contains the <link> tag that points to the new css file. And since as you said, you will be editing the css file quite often, I recommend just adding ?v=1 to the querystring and then whenever you edit the css file, change it to 2, 3, 4..and so on.

              Code:
              <link rel="stylesheet" type="text/css" href="{vb:raw baseurl}/css/background.css[COLOR=#FF0000]?v=1[/COLOR]" />
              Or why don't you just add the custom css to css_additional.css template instead of adding a new css file?

              GIPHY for vB5 AutoLinker Auto-Create Flag Report INITIALS AVATAR (Better) Name Card Quote Selected Text Likes Summary Disable AJAX Pagination Stop Links in Posts...& MORE!

              Comment


              • #8
                Originally posted by Mark.B View Post
                There is no bug with the header template, it is able to be edited fine.

                I can give you access to my forum and you'll see yourself.

                Edit:

                I had even make a video to show you this bug. It is like this since upgrade from 3.8.x

                https://www.youtube.com/watch?v=BArLKqwvXQM
                Last edited by ibeauty; Tue 2 Dec '14, 6:28am.

                Comment


                • #9
                  Originally posted by ibeauty View Post
                  And there is some bug in vB that i cannot change header template directly. I have to revert header template then I can modify it. It is annoying as hell, so I decide to download one more file.
                  You're not alone.

                  http://www.vbulletin.com/forum/forum...nflict-message


                  Going back to the original issue, have you tried my suggestion in post #7?

                  GIPHY for vB5 AutoLinker Auto-Create Flag Report INITIALS AVATAR (Better) Name Card Quote Selected Text Likes Summary Disable AJAX Pagination Stop Links in Posts...& MORE!

                  Comment


                  • #10
                    Well, no. I had changed line into:

                    <link rel="stylesheet" type="text/css" href="{vb:raw baseurl}/css/background.css?{vb:date timestamp}">
                    and it works fine enough.

                    Comment


                    • #11
                      Originally posted by ibeauty View Post
                      Well, no. I had changed line into:

                      <link rel="stylesheet" type="text/css" href="{vb:raw baseurl}/css/background.css?{vb:date timestamp}">
                      and it works fine enough.
                      It works but the css file will not ever be cached by the browser. That's ok for debugging purposes but not on live site.

                      GIPHY for vB5 AutoLinker Auto-Create Flag Report INITIALS AVATAR (Better) Name Card Quote Selected Text Likes Summary Disable AJAX Pagination Stop Links in Posts...& MORE!

                      Comment


                      • #12
                        Well, it would be cached once each day. Maybe it is not best for live site, but I don't have resources to remember that file had been changed. There have been also problem with refreshing css after editing CSS templates -> css_global.css . The &ts= parameter in css.php request didn't change, even after clearing to cache. So I had decided for such easier, but maybe not optimal solution. And I don't want to dive into your code to fix bugs.

                        Comment

                        widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                        Working...
                        X