Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource functions

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 302 to 329

Definition

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

    if(
trim($fromdate==""))
        {
        
$tstamp time();
        }
    else
        {
        
$date = new DateTime($fromdate);
        
$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 24th November 2020 06:05 Europe/London time based on the source file dated 23rd November 2020 10:40 Europe/London time.