The WordPress current_time()
returns the current time in the format specified in the first parameter. In your example code, this is the mysql
value. The second parameter represents a timezone option. The default returns the local time for the timezone specified on the site’s Settings > General page, or GMT depending on the value supplied when calling the function.
https://codex.wordpress.org/Function_Reference/current_time
If time mathematics are still required, using the PHP strtotime()
function is useful for this:
$now = current_time( 'mysql' );
echo 'It is currently: ' . $now . '<br>';
$later = date( 'Y-m-d H:i:s', strtotime( $now ) + 7200 ); //7200 seconds = 2 hours
echo 'In 2 hours it will be: ' . $later;
Related Posts:
- Copyright: Get first and last date of post type
- User set date and time from frontend doesn’t get stored into database
- How to convert a string to date in MySQL?
- MySQL date formats – difficulty Inserting a date
- How to use greater than operator with date?
- SQL query to update post_date (one post = one single date & time)
- Is a MySQL DATETIME or TIMESTAMP value retrieved through $wpdb in UTC?
- How do I join a $wpdb query with user meta using default value if not exist?
- MySQL Error: : ‘Access denied for user ‘root’@’localhost’
- ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
- Can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock’ (38)
- ERROR 1698 (28000): Access denied for user ‘root’@’localhost’
- ERROR 1698 (28000): Access denied for user ‘root’@’localhost’
- When to use SELECT … FOR UPDATE?
- ERROR 1396 (HY000): Operation CREATE USER failed for ‘jack’@’localhost’
- Getting “Lock wait timeout exceeded; try restarting transaction” even though I’m not using a transaction
- Search for all occurrences of a string in a mysql database
- how to overcome ERROR 1045 (28000): Access denied for user ‘ODBC’@’localhost’ (using password: NO) permanently
- #1045 – Access denied for user ‘root’@’localhost’ (using password: YES)
- MySQL COUNT DISTINCT
- How to update a record using sequelize for node?
- Can’t open the mysql.plugin table. Please run mysql_upgrade to create it
- Convert MySQL to SQlite [closed]
- Create a temporary table in a SELECT statement without a separate CREATE TABLE
- Convert partially non-numeric text into number in MySQL query
- MySql: is it possible to ‘SUM IF’ or to ‘COUNT IF’?
- MySQL: What’s the difference between float and double?
- How can I search (case-insensitive) in a column using LIKE wildcard?
- MySQL Select Multiple VALUES
- SQL – IF EXISTS UPDATE ELSE INSERT INTO
- How to unblock with mysqladmin flush hosts
- Node.js MySQL – Error: connect ECONNREFUSED
- Solution to “subquery returns more than 1 row” error
- MySQL Error #1071 – Specified key was too long; max key length is 767 bytes
- How To have Dynamic SQL in MySQL Stored Procedure
- MySQL – UPDATE query with LIMIT
- MySQL said: Documentation #1045 – Access denied for user ‘root’@’localhost’ (using password: NO)
- What SQL Query to do a simple find and replace
- Scanning Database for malicious Data
- how to refresh wordpress permalink settings? (without admin panel)
- Ordering posts by day (not time) AND meta value
- wpdb->prepare function remove single quote for %s in SQL statment
- Problems with DBDelta with FOREIGN key?
- Is it useful to turn on MySQL query cache for performance
- Programmatically changing role information; editing role name and deleting
- How to let a user choose an authors and save it to the database?
- Search and replace in post content
- Use meta_query to display events by date in custom field
- Date and time format for UK in a custom post type [closed]
- Join new table with SQL query
- WordPress installation on valet php 8 (PHP Fatal error: Uncaught mysqli_sql_exception Table ‘wp_options’ doesn’t exist in wp-includes/wp-db.php:2056)
- MySQL crashed because of the large number of requests
- Why doesn’t this code add a table to my database?
- SQL database export-import
- Can Someone Help Me Fix This WordPress Missing Argument Error?
- How do I get create a custom table showing the hours remaining for all customers in one page from this transactions page?
- Uncaught Error: Call to undefined function mysql_connect() – WordPress installation
- SQL Database, repeated tables?
- Visual/Text Editor displays blank pages in WP-Admin- but HTML on client side displays correctly
- Code to remove authors with no posts connected to them
- Format Date for Manual Insertion into post
- Translate current_time
- SQL Query in WordPress – Getting Impossible WHERE error
- WordPress create database not working
- How can I compare publish and update dates for a single post?
- database optimization and server errors
- Setting up WordPress Locally on WAMP for a new site (with one already)
- Calling mysql_query() on another database, assumes WordPress using that database
- WordPress VIP realpath Alternative?
- querying user bookmarks from a large number of bookmarks
- Pull post name from value of a specific meta key
- PHP variables in mysql query
- How to fix the amount of comments displayed for each post?
- wordpress built-in Jalali date convertor
- How do I echo all users’ display_name and their meta_value who have a certain meta_key?
- How to simulate web traffic to test performance of a website
- SQL query to change custom field in WordPress database
- Can’t convert ACF datepicker value to DateTime oject – gives me a boolean
- SQL. Select category descendants
- MySQL Actibity without any active visitors via Google Analytics
- How do you update post date (year only) in a separate custom field?
- How to configure WordPress Database for CentOS 7
- Why is local wordpress install calling live site executions?
- Display MySQL as part of a Page
- Migration of wordpress database from mariadb 10.0.20 to 5.5.50
- WP Meta Query – mixed AND / OR query doesn’t work
- Display Year and Month from custom field + Age Calculator
- automatic send email at custom time
- Second completely independent and disposable WordPress installation in subdirectory?
- get_results suddenly not working on a single table
- How to second orderby in “pre_get_posts” by meta value or combine single date and time to timestamp
- Internal error (500) on local & Fatal error on live when trying to access post type edit screen
- Query sql for truncate post_content in wp_posts table
- How WP decide to show or not to show in admin panel the pop-up window with hint? Need a fix
- Foreach only outputs if id is 0
- “Error 1064” when importing msql database after updating wordpress version to 4.2.1
- Initialization of table in database using ‘CREATE … IF NOT EXISTS’
- mysqldump throws: Unknown table ‘COLUMN_STATISTICS’ in information_schema (1109)
- How do I load a sql.gz file to my database? (importing)
- Batch Replace URLs in WordPress Database