mix_date()

Description

Utility function to randomly alter date by offset

Parameters

ColumnTypeDefaultDescription
$fromdate string - date string
$maxoffset int 30 - Maximum number of days to offset

Return

string

Location

include/migration_functions.php lines 230 to 252

Definition

 
function mix_date($fromdate$maxoffset 30)
{
    global 
$mixcache;
    if (isset(
$mixcache[md5($fromdate)])) {
        return 
$mixcache[md5($fromdate)];
    }

    if (
trim($fromdate == "")) {
        
$tstamp time();
    } else {
        
$tstamp strtotime($fromdate);
    }

    
$dateshift 60 60 24 $maxoffset// How much should dates be moved
    
$newstamp $tstamp + (mt_rand(-$dateshift$dateshift));
    
$newdate gmdate('Y-m-d H:i:s'$newstamp);
    
debug("Converted date " $fromdate " to " $newdate);

    
// Update cache
    
$mixcache[md5($fromdate)] = $newdate;

    return 
$newdate;
}

This article was last updated 20th June 2025 21:35 Europe/London time based on the source file dated 23rd May 2025 11:20 Europe/London time.