Announcement

Collapse
No announcement yet.

How to format date/time

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

  • OldGrumpyDad
    replied
    That's the ticket. Just setting time options everywhere did the trick. But I'm surprised I can't override it in the template for a specific widget.

    Leave a comment:


  • Wayne Luke
    replied
    Settings -> Options -> Date and Time Options. Make sure to read the inline help to see links to all the options supported. These options recently changed in 5.6.3 so that we can try to consolidate the different methods PHP uses to format dates depending on whether you're using a Locale or not.

    If you have multiple languages and want to format the date and time for those languages differently from the default, then you can do this in the Languages & Phrases -> Language Manager tool. Each language can have its own format.

    Leave a comment:


  • OldGrumpyDad
    replied
    I'm not, really. I was being persnickety and wanted to get rid of the leading zero. It's not the 1980s any more. We have the ability to write things that look natural. There's no reason for a web site, in the year of our Lord 2020, to write "03:04 PM" instead of "3:04pm" or something prettier. I thought this would be super simple and was surprised how I couldn't do it at all.

    Feel free to share the 24-hour time solution, in case it helps. But I was really just trying to change the format to look more modern and less Kernighan & Ritchie.

    Leave a comment:


  • In Omnibus
    replied
    Are you trying to change it to 24 hour time? If so there's an easier way.

    Leave a comment:


  • OldGrumpyDad
    started a topic [Resolved] How to format date/time

    How to format date/time

    In templates like widget_onlineusers we have expressions that use the {vb:datetime} function. Reading core/vb/template/runtime.php it seems like the datetime function takes a number of arguments. I'm trying to figure out how to set a time format.

    The default template has this: {vb:datetime {vb:raw onlineUserCounts.maxonlinedate}, time}. It results in a time format like "03:04 PM", which I would like to adjust. In theory, if we follow standard PHP notation, which it gets from C's strftime(), I could probably use "%l:%M" to get " 3:04 PM" or I could use "%I:%M" to get "15:04". I looked at the vb5 connect template syntax in the documentation, but the datatime function isn't listed there. I don't know how to pass the format to the datetime function.

    I've tried, for example, changing the template to {vb:datetime {vb:raw onlineUserCounts.maxonlinedate}, time, formattime="%h:%m:%s"} } but I still see "03:04 PM" in the output. What's the syntax to set the time format?
widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Working...
X