Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test 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 17th November 2024 15:05 Europe/London time based on the source file dated 15th April 2024 16:05 Europe/London time.