Collections functions
General functions
Node functions
Render functions
Theme permission functions
User 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 252 to 278

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 19th March 2024 05:05 Europe/London time based on the source file dated 26th February 2024 11:00 Europe/London time.