Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
eZTime Class Reference
Locale system

Locale aware time handler. More...

## Public Member Functions
| __construct ( $timestamp=false)
| attributes ()
| hasAttribute ( $name)
| attribute ( $name)
| isValid ()
| setLocale (&$locale)
& | locale ()
| setHour ( $hour)
| setMinute ( $min)
| setSecond ( $sec)
| setHMS ( $hour, $min=0, $sec=0)
| hour ()
| minute ()
| second ()
| timeStamp ()
| setTimeStamp ( $timestamp)
| timeOfDay ()
| setTimeOfDay ( $timestamp)
| adjustTime ( $hour, $minute=0, $second=0)
| duplicate ()
| isGreaterThan (&$time, $equal=false)
| isEqualTo (&$time)
| toString ( $short=false)

## Static Public Member Functions
static | create ( $hour=-1, $minute=-1, $second=-1)
static | secondsPerDay ()

## Public Attributes
| $IsValid
const | SECONDS_A_MINUTE = 60
const | SECONDS_AN_HOUR = 3600
const | SECONDS_A_DAY = 86400
| $Locale
| Locale object, is just a reference to minimize memory usage. More...
| $Time
| The current time as a clamped timestamp. More...

## Detailed Description

Locale aware time handler.

eZTime handles 24 hour time values in hours, minutes and seconds. The time stored as a timestamp clamped to a 24 hour day, ie 86400.

A new instance of eZTime will automaticly use the current locale and current time, if you however want a different locale use the setLocale() function. The current locale can be fetched with locale().

You can also change the time directly with setHour(), setMinute(), setSecond() and setHMS(). You can also adjust the time relative to it's current value by using adjustTime(). Use timeStamp() to get the current timestamp value or hour(), minute() and second() for the respective values.

When creating new times you're advised to use the static create() function which returns a new eZTime object. You can also create a copy with the duplicate() function.

Time checking is done with the isGreaterThan() and isEqualTo() functions.

Text output is done with toString() which can return a long string (default) or short string representation according to the current locale.

Example:

$us_locale = eZLocale::instance( 'us' );
$time1 = new eZTime();
$time2 = eZTime::create();
$time2->setLocale( $us_locale );
$time2->adjustTime( -8 );
$time3 = $time1->duplicate();
print( $time1->toString() );
print( $time2->toString( true ) );
print( $time1->isEqualTo( $time3 ) ? 'true' : 'false' ); // Prints 'true'
eZLocale\instance
static instance( $localeString=false)
Definition: ezlocale.php:1536
eZTime
Locale aware time handler.
Definition: eztime.php:59
eZTime\create
static create( $hour=-1, $minute=-1, $second=-1)
Definition: eztime.php:278

See also
  eZDate, eZDateTime, eZLocale

Definition at line 58 of file eztime.php.

## Constructor & Destructor Documentation

## ◆ __construct()

eZTime::__construct | ( |  | $timestamp = `false` | ) |

Creates a new time object with default locale, if $time is not supplied the current time is used.

Parameters

  int | bool | $timestamp |

Definition at line 81 of file eztime.php.

References eZLocale\instance(), setHMS(), setTimeOfDay(), and setTimeStamp().

## Member Function Documentation

## ◆ adjustTime()

eZTime::adjustTime | ( |  | $hour,
|  |  | $minute = `0`,
|  |  | $second = `0`
| ) |  |

Adjusts the time relative to it's current value. This is useful for adding/subtracting hours, minutes or seconds to an existing time.

Definition at line 267 of file eztime.php.

References setTimeOfDay().

## ◆ attribute()

eZTime::attribute | ( |  | $name | ) |

Definition at line 113 of file eztime.php.

References hour(), isValid(), minute(), second(), timeOfDay(), timeStamp(), and eZDebug\writeError().

## ◆ attributes()

eZTime::attributes | ( |  | ) |

Definition at line 98 of file eztime.php.

Referenced by hasAttribute().

## ◆ create()

static eZTime::create | ( |  | $hour = `-1`,
|  |  | $minute = `-1`,
|  |  | $second = `-1`
| ) |  |
| static

Creates a new eZTime object with the time values $hour, $min and $sec and returns a reference to it. Any value can be ommitted or set to -1 to use the current time value.

Definition at line 278 of file eztime.php.

## ◆ duplicate()

eZTime::duplicate | ( |  | ) |

Deprecated:
  This function is deprecated in PHP5, use the PHP5 clone keyword instead Creates an exact copy of this object and returns it.

Definition at line 293 of file eztime.php.

## ◆ hasAttribute()

eZTime::hasAttribute | ( |  | $name | ) |

Definition at line 108 of file eztime.php.

References attributes().

## ◆ hour()

eZTime::hour | ( |  | ) |

Returns the hour element.

Definition at line 195 of file eztime.php.

References SECONDS_AN_HOUR.

Referenced by attribute(), setMinute(), setSecond(), and timeStamp().

## ◆ isEqualTo()

eZTime::isEqualTo | ( | & | $time | ) |

Returns true if this object is equal to $time. $time can be specified as a timestamp value or as an eZTime object.

Definition at line 323 of file eztime.php.

References $Time, and SECONDS_A_DAY.

## ◆ isGreaterThan()

eZTime::isGreaterThan | ( | & | $time,
|  |  | $equal = `false`
| ) |  |

Returns true if this object has a time greater than $time. $time can be specified as a timestamp value or as an eZTime object. If $equal is true it returns true if they are equal as well.

Definition at line 304 of file eztime.php.

References $Time, and SECONDS_A_DAY.

## ◆ isValid()

eZTime::isValid | ( |  | ) |

Returns
  true if the date has valid data.

Definition at line 135 of file eztime.php.

References $IsValid.

Referenced by attribute().

## ◆ locale()

& eZTime::locale | ( |  | ) |

Returns a reference to the current locale.

Definition at line 151 of file eztime.php.

References $Locale.

## ◆ minute()

eZTime::minute | ( |  | ) |

Returns the minute element.

Definition at line 203 of file eztime.php.

References SECONDS_AN_HOUR.

Referenced by attribute(), setHour(), setSecond(), and timeStamp().

## ◆ second()

eZTime::second | ( |  | ) |

Returns the second element.

Definition at line 211 of file eztime.php.

References SECONDS_A_MINUTE.

Referenced by attribute(), setHour(), setMinute(), and timeStamp().

## ◆ secondsPerDay()

static eZTime::secondsPerDay | ( |  | ) |
| static

Deprecated:
  Use eZTime::SECONDS_A_DAY instead Get number of seconds per day

Definition at line 351 of file eztime.php.

References SECONDS_A_DAY.

## ◆ setHMS()

eZTime::setHMS | ( |  | $hour,
|  |  | $min = `0`,
|  |  | $sec = `0`
| ) |  |

Sets all hour, minute and second elements.

Definition at line 186 of file eztime.php.

Referenced by __construct().

## ◆ setHour()

eZTime::setHour | ( |  | $hour | ) |

Sets the hour leaving the other elements untouched.

Definition at line 159 of file eztime.php.

References minute(), and second().

## ◆ setLocale()

eZTime::setLocale | ( | & | $locale | ) |

Sets the locale to $locale which is used in text output.

Definition at line 143 of file eztime.php.

## ◆ setMinute()

eZTime::setMinute | ( |  | $min | ) |

Sets the minute leaving the other elements untouched.

Definition at line 168 of file eztime.php.

References hour(), and second().

## ◆ setSecond()

eZTime::setSecond | ( |  | $sec | ) |

Sets the second leaving the other elements untouched.

Definition at line 177 of file eztime.php.

References hour(), and minute().

## ◆ setTimeOfDay()

eZTime::setTimeOfDay | ( |  | $timestamp | ) |

Definition at line 254 of file eztime.php.

References SECONDS_A_DAY.

Referenced by __construct(), and adjustTime().

## ◆ setTimeStamp()

eZTime::setTimeStamp | ( |  | $timestamp | ) |

Definition at line 234 of file eztime.php.

Referenced by __construct().

## ◆ timeOfDay()

eZTime::timeOfDay | ( |  | ) |

Returns the timestamp value, this is not the number of seconds since the epoch but a clamped value to the number of seconds in a day.

Definition at line 246 of file eztime.php.

References $Time.

Referenced by attribute().

## ◆ timeStamp()

eZTime::timeStamp | ( |  | ) |

Definition at line 219 of file eztime.php.

References hour(), minute(), and second().

Referenced by attribute(), and toString().

## ◆ toString()

eZTime::toString | ( |  | $short = `false` | ) |

Creates a string representation of the time using the current locale and returns it. If $short is true a short representation is used.

Definition at line 337 of file eztime.php.

References timeStamp().

## Member Data Documentation

## ◆ $IsValid

eZTime::$IsValid

Definition at line 60 of file eztime.php.

Referenced by isValid().

## ◆ $Locale

eZTime::$Locale

Locale object, is just a reference to minimize memory usage.

Definition at line 357 of file eztime.php.

Referenced by locale().

## ◆ $Time

eZTime::$Time

The current time as a clamped timestamp.

Definition at line 359 of file eztime.php.

Referenced by isEqualTo(), isGreaterThan(), and timeOfDay().

## ◆ SECONDS_A_DAY

const eZTime::SECONDS_A_DAY = 86400

Number of seconds in a day.

Definition at line 74 of file eztime.php.

Referenced by isEqualTo(), isGreaterThan(), secondsPerDay(), and setTimeOfDay().

## ◆ SECONDS_A_MINUTE

const eZTime::SECONDS_A_MINUTE = 60

Number of seconds in a minute.

Definition at line 64 of file eztime.php.

Referenced by second().

## ◆ SECONDS_AN_HOUR

const eZTime::SECONDS_AN_HOUR = 3600

Number of seconds in an hour.

Definition at line 69 of file eztime.php.

Referenced by hour(), and minute().

The documentation for this class was generated from the following file:

- eztime.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.