Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4015656
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:38:44+00:00 2026-05-20T09:38:44+00:00

Is it possible to somehow setback the date of the current_time function in wordpress?

  • 0

Is it possible to somehow setback the date of the current_time function in wordpress?

Right now i am using it like this:

$time = current_time('mysql');

I would like to get the same year, month and time.. but set back the day with for example 2.

Any ideas guys? 🙂

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:38:45+00:00Added an answer on May 20, 2026 at 9:38 am
    function days_ago($days, $type, $gmt=0) {
        $time = $gmt? time() : time() + ( get_option('gmt_offset')*3600 );
        $d = explode('-', date('H-i-s-n-j', $time));
        $time = mktime($d[0], $d[1], $d[2], $d[3], $d[4]-$days);
        return $type=='mysql'? gmdate('Y-m-d H:i:s', $time) : $time;
    }
    

    It works just like current_time(), except that you pass it a number of days:

    $time = days_ago(2, 'mysql');
    

    Note that if you didn’t need the $type and $gmt options that current_time() provides, you could use this instead:

    function days_ago($days) {
        $d = explode('-', date('H-i-s-n-j'));
        return date('Y-m-d H:i:s', mktime($d[0], $d[1], $d[2], $d[3], $d[4]-$days));
    }
    
    $time = days_ago(2);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

is it possible somehow to use the NOW() function or something similar in MYSQL
is this possible somehow? I would like to redirect to different pages depending on
Is it possible somehow to close StreamReader after calling ReadToEnd method in construction like
is it somehow possible to call a rails function or to access a rails
I'm wondering, is it possible to somehow map a key-press event to act like
Is is possible somehow to pop up Input Mask Editor at run-time? I was
Is this possible somehow? @Name(geolocationService) public interface GeolocationService { @Query(SELECT g FROM Geolocation geolocation
Is this possible somehow? I mean for my own bundle? Thank you Misha p.s.
Sounds like silly idea but I was wondering if it's possible somehow. Is it
in a jQuery plugin i have created helper functions, like this (function($) { var

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.