/**
 * Is today.
 * Determines if the given timestamp is today.
 * @author Sam Barrow
 * @param int Timestamp
 * @return bool Is today
**/

function dt_isToday($timestamp) {
    return date('z/Y', $timestamp) === date('z/Y', time());
}

/**
 * Is yesterday.
 * Determines if the given timestamp occured yesterday.
 * @author Sam Barrow
 * @param int Timestamp
 * @return bool Is yesterday
**/

function dt_isYesterday($timestamp) {
    return date('z/Y', $timestamp) === date('z/Y', time() - dt_days(1));
}

/**
 * Is weekday.
 * Determines if the given timestamp occurs on a weekday.
 * @author Sam Barrow
 * @param int Timestamp
 * @return bool Is weekday
**/

function dt_isWeekday($timestamp) {
    return in_array((int) date('N', $timestamp), array(2, 3, 4, 5, 6), true) ;
}

/**
 * Is weekend.
 * Determines if the given timestamp occurs on a weekend.
 * @author Sam Barrow
 * @param int Timestamp
 * @return bool Is weekend
**/

function dt_isWeekend($timestamp) {
    return in_array((int) date('N', $timestamp), array(1, 7), true) ;
}

/**
 * Is this hour.
 * Determines if the given timestamp is in the current hour.
 * @author Sam Barrow
 * @param int Timestamp
 * @return bool Is this hour
**/

function dt_isThisHour($timestamp) {
    return date('H/d/m/Y', $timestamp) === date('H/d/m/Y', time());
}

/**
 * Is this minute.
 * Determines if the given timestamp is in the current minute.
 * @author Sam Barrow
 * @param int Timestamp
 * @return bool Is this minute
**/

function dt_isThisMinute($timestamp) {
    return date('i/H/z/Y', $timestamp) === date('i/H/z/Y', time());
}

/**
 * Is this month.
 * Determines if the given timestamp is in the current month.
 * @author Sam Barrow
 * @param int Timestamp
 * @return bool Is this month
**/

function dt_isThisMonth($timestamp) {
    return date('m/Y', $timestamp) === date('m/Y', time());
}

/**
 * Is this week.
 * Determines if the given timestamp is in the current week.
 * @author Sam Barrow
 * @param int Timestamp
 * @return bool Is this week
**/

function dt_isThisWeek($timestamp) {
    return date('W/Y', $timestamp) === date('W/Y', time());
}

/**
 * Is this year.
 * Determines if the given timestamp is in the current year.
 * @author Sam Barrow
 * @param int Timestamp
 * @return bool Is this year
**/

function dt_isThisYear($timestamp) {
    return date('Y', $timestamp) === date('Y');
}

/**
 * From days.
 * Converts days to seconds.
 * @author Sam Barrow
 * @param int Days
 * @return int Seconds
**/

function dt_fromDays($days) {
    return $days * 86400;
}

/**
 * From hours.
 * Converts hours to seconds.
 * @author Sam Barrow
 * @param int Hours
 * @return int Seconds
**/

function dt_fromHours($hours) {
    return $hours * 60 * 60;
}

/**
 * From minutes.
 * Converts minutes to seconds.
 * @author Sam Barrow
 * @param int Minutes
 * @return int Seconds
**/

function dt_fromMinutes($minutes) {
    return $minutes * 60;
}

/**
 * From weeks.
 * Converts weeks to seconds.
 * @author Sam Barrow
 * @param int Weeks
 * @return int Seconds
**/

function dt_fromWeeks($weeks) {
    return $weeks * 86400 * 7;
}

/**
 * From years.
 * Converts years to seconds.
 * @author Sam Barrow
 * @param int Years
 * @return int Seconds
**/

function dt_fromYears($years) {
    return $years * 86400 * 365;
}

/**
 * To days.
 * Converts seconds to days.
 * @author Sam Barrow
 * @param int Seconds
 * @return int Days
**/

function dt_toDays($seconds) {
    return dt_toHours($seconds) / 24;
}

/**
 * To hours.
 * Converts seconds to hours.
 * @author Sam Barrow
 * @param int Seconds
 * @return int Hours
**/

function dt_toHours($seconds) {
    return dt_toMinutes($seconds) / 60;
}

/**
 * To minutes.
 * Converts seconds to minutes.
 * @author Sam Barrow
 * @param int Seconds
 * @return int Minutes
**/

function dt_toMinutes($seconds) {
    return $seconds / 60;
}

/**
 * To weeks.
 * Converts seconds to weeks.
 * @author Sam Barrow
 * @param int Seconds
 * @return int Weeks
**/

function dt_toWeeks($seconds) {
    return dt_toDays($seconds) / 7;
}

/**
 * To years.
 * Converts seconds to years.
 * @author Sam Barrow
 * @param int Seconds
 * @return int Years
**/

function dt_toYears($seconds) {
    return dt_toDays($seconds) / 365;
}