The trick here is using wp_date() in a peculiar way, giving it the time of day in seconds (as if it were 1970-01-01 16:42:18
), then asking for it to be formatted in UTC.
$time="16:42:18";
if ( preg_match( '/^\d\d:\d\d:\d\d$/', $time ) ) { //validate the $time
$ts = intval( substr( $time, 0, 2 ) ) * 3600;
$ts += intval( substr( $time, 3, 2 ) ) * 60;
$ts += intval( substr( $time, 7, 2 ) );
if ( $ts >= 0 && $ts < 86400 ) {
$time = wp_date( get_option( 'time_format' ), $ts, 'UTC' );
}
}
Related Posts:
- Change the ‘published on’ text?
- How are themes and plugins localized using the gettext GNU framework?
- ajaxurl not defined on front end
- How to include jQuery and JavaScript files correctly?
- How can I configure Docker for developing and deploying a custom theme?
- Where to store PHP files created by plugin / themes
- How to post data to same page in wordpress
- Understanding WordPress functions’ naming conventions
- Is there widely accepted phpDoc syntax for documenting which hook calls a function?
- How do I Make a Theme “plugin-ready”?
- How to Add a .js file Only in one specific Page Dynamically to Head
- Show a user their recently viewed posts
- Escaping built-in WP function return strings
- How to use filter hook ‘post_updated_messages’ in coherence with action hook ‘save_post’
- Add new user and add meta at once
- How to properly load text domain of custom mu plugin
- Custom user profile, registration, login page with theme
- How to Display Custom Post Type’s Gallery (images ) in Through WP_Query
- Customizer Not Saving Options
- WordPress: After Gutenberg plugin migration to block.json the localization/ translations with PolyGlot in JavaScript does not work anymore
- What is better way to use Bootstrap inside admin panel?
- Error : “Updating failed: The response is not a valid JSON response” with custom shortcode
- What’s the better way to add an inline script?
- Backslashes being stripped from CSS
- What for the tables ending with the meta used in database of wordpress?
- How to determine if the current file is loaded in a plugin or in a theme?
- Finding the paragraphs in content
- Is Dreamweaver CS5 a serious choice for theme/plugin development?
- What allows a template file from plugin to be copied in child theme and overridden?
- How to avoid loading same script twice?
- Can I individually style items in the backend widget list?
- WordPress security issue to output data from user input from theme option form
- Finding posts containing matching array elements in a meta field usign WP_Query
- Customizer: widget-synced triggers twice
- How to Create Custom HTML Tag on Editor in `Text(HTML)` mode
- Is It Always a Best Practice to Decouple the Frontend from the Admin Area When Developing a WordPress Application?
- Should shorcodes in i18n plugins be translated and if so, how?
- A better way to include localized labels in WordPress plugins
- Beginner advice
- Are block templates incompatible with serialize_blocks?
- How to filter users list on user_status field with get_users()
- SQL query for custom taxonomy slugs
- Can Page Templates be Applied to Archive and Post Templates?
- Is there some way to provide the user a list of existing content in a CPT
- Change the look and feel of admin pages
- Generate JSON files for language translation from po file without wp-cli i18n make-json
- Form doesnt save to database
- Notice: Trying to get property ‘term_id’ of non-object
- What is the proper method of using global $post?
- How to change title tag at page after loaded post?
- WordPress custom taxonomy check box to dropdown
- load_plugin_textdomain doestn’t work with add_action plugins_loaded
- Selectively update themes in WordPress multisite
- How to prevent someone from entering strings without making it available for translation?
- I18n not working in plugin
- Getting a WordPress Debug Strategy
- Apply styles to blockquote element with the WYSIWYG editor
- Mixing l18n string from my plugin with WordPress’ translations
- Conditional Generation of Image Sizes using add_image_size
- How to add plugin options in wp editor page
- Is hint for translator compulsory while internationalizing a string containing variables?
- Gutenberg blocks error: Each child in a list should have a unique “key” prop
- WP Still Generating 150×150 Thumbnail Size Even After Un-Setting Small Size in Functions.php
- Does WordPress default CSS have Grids?
- How to resize WordPress images on upload to specific height and width without cropping it
- Create fixed static pages
- rewrite_rules problem
- Why does website stretch and white space on load? [duplicate]
- Why my theme’s css not working on another site
- Pass custom props to
- Include external po file for 3th party plugin to theme
- How to make premium plugin? I want to limit it until verification
- Google Web Core Vitals – management, how to in wordpress and advice
- Override category archive page title (not the head title)
- How to hide/remvoe unnecessary field/section in post edit section ( Dashboard )
- Scripts/styles not loading on cloned WP Site when logged in
- redirect_to how to make it simply work with get parameter or similar?
- Determine if the current page, is being edited
- Is it possible to modify an Elated plugin portfolio-list template in such a way that it will not conflict with future plugin updates?
- Woocommerce Custom Checkout
- Dynamic sidebar areas not working on the Theme Customizer
- Looping single post in a theme
- Merge Codes using redux framework
- WordPress permalink setting
- Custom theme and plugin updating
- Issue on Getting Images URL of the Post Gallery
- variable created in page.php is null inside of header.php
- Adding class to the parent of current-post-ancestor / current-menu-parent / current-post-parent
- problem with blank page
- grouping my widgets wordpress
- Updating Style From WP Options Setting Page
- Create and style menu
- If I want to create new taxonomies (e.g. Project / Documents / Etc…) is it better to create them in the theme’s functions.php or within a plugin? [duplicate]
- How to add something after a function
- Problem with Poedit [closed]
- Is Explicit Versioning a better alternative to Semantic Versioning for wordpress?
- how many rupee or dollar charge to client to make theme [closed]
- How to get the value entered in the input field in wordpres
- React Plugin Settings Page Localization
- Why isn’t custom sidebar panel not showing up in the Gutenberg Editor?