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?
- Autoloading & Namespaces in WordPress Plugins & Themes: Can it Work?
- framework for plugin/theme options panel? [closed]
- How to get the path to the current theme?
- ajaxurl not defined on front end
- What process do you use for WordPress development? [closed]
- Why does WordPress use outdated jQuery v1.12.4?
- What is the advantage of using wp_mail?
- How to make a WordPress plugin translation ready?
- Should Plugin Folders Include a Blank index.php File?
- How to include jQuery and JavaScript files correctly?
- Single functions.php or split into many small files?
- 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
- What is an alternative method to the WordPress private _doing_it_wrong() function
- How to provide translations for a WordPress TinyMCE plugin?
- Understanding WordPress functions’ naming conventions
- What is the difference between esc_html and wp_filter_nohtml_kses?
- Should I create a theme or a plugin?
- Include third party Javascript library which is not included in WordPress
- Is there widely accepted phpDoc syntax for documenting which hook calls a function?
- Where do I start from
- WP 3.3 Tooltips API?
- jQuery in header or footer
- Check for featured image in WP_Query
- wp_remote_get doesn’t work with secure connections https?
- Update exisiting site to 3.5 release candidate
- How do I Make a Theme “plugin-ready”?
- Preparing a string in an array for localization
- Authoritative answer on which boots first – Plugins or Themes?
- How to Add Font Awesome Icons to WordPress Menus?
- 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 WordPress Color Picker API in Custom Post Type Metabox
- Get file headers in custom file
- add_filter and remove_filter added before and after wp_query
- What is the difference between strip_tags and wp_filter_nohtml_kses?
- Shortcodes, output buffering, and WordPress functions
- Custom theme sufficient or custom plugin neccessary for this feature set?
- Problems with localization
- Having Problem On Getting WP Post Gallery Images URL
- What’s the difference between hooks, filters and actions? [duplicate]
- How to use filter hook ‘post_updated_messages’ in coherence with action hook ‘save_post’
- Multiple textdomains
- How to create custom home page via plugin?
- Add new user and add meta at once
- How to properly load text domain of custom mu plugin
- How to: get main plugin/theme file?
- How to debug WordPress correctly?
- `wp_set_script_translations` with `wp.i18n` does not return translated strings in simple plugin
- Custom user profile, registration, login page with theme
- add_theme_support using a plugin
- WordPress Localization and Templating
- Featured Image not showing in admin
- How to properly load text domain of custom mu plugin
- How to Display Custom Post Type’s Gallery (images ) in Through WP_Query
- Customizer Not Saving Options
- How to bundle a plugin with a theme, or vice versa
- Can’t we use strings defined as PHP constants if we want to translate them in a plugin?
- How to update the language used by wordpress from a plugin
- 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?
- Singular name Plugin localization
- How to add Font Awesome 5 icons in WP Admin dashboard menu?
- How Can I setup WP CLI on Windows development machine running AMPPS?
- WP_LOCALIZE_SCRIPT doesn’t work
- What is the difference between these two methods of writing $ instead of jQuery in WordPress [closed]
- Whats the difference between blog_info(‘stylesheet_url’) difference get_stylesheet_uri()
- Error : “Updating failed: The response is not a valid JSON response” with custom shortcode
- What’s the better way to add an inline script?
- What function to hook for changes made in status and visibility of a post
- Example of uninstaller routine to remove all custom theme options from wp_options
- Metabox Not Showing on Custom Post Type But On Pages and Post
- Modify a Free Plugin available on wordpress.org & include with my Premium Theme? [closed]
- Paging on a future post loop?
- Display future posts?
- Execution limit and Memory limit errors even i changed to 1024M and 600(cache.php,load.php)?
- Are we allowed to use the Allman (BSD) indent style when coding WordPress plugins and themes?
- Backslashes being stripped from CSS
- Best choice of options/settings framework for plugin/theme development
- 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?
- Is there any way to have Featured Text, as opposed to Featured Image?
- How to check if a stylesheet is already loaded?
- Find source of notice / warning / errors efficiently
- Problem with is_active_sidebar?
- Filter, or any way to dynamically change theme screenshot image?
- How to i18n text coming from the db or from an external source
- Finding the paragraphs in content
- Is Dreamweaver CS5 a serious choice for theme/plugin development?
- StackExchange clone using WordPress?
- What allows a template file from plugin to be copied in child theme and overridden?
- Sharing common functionality (functions, template parts) between plugins and themes?
- 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
- WP_Query returns no results