Can you really in some way setback the date from the current_time function in wordpress?

Right now i'm utilizing it such as this:

$time = current_time('mysql');

I must obtain the same year, month and time.. but challenge your day with for instance 2.

Any ideas men? :)


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 really works much like current_time(), with the exception that you pass it numerous days:

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

Observe that should you did not require the $type and $gmt options that current_time() provides, you could utilize this rather:

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);