EQdkp Plus Navigation:   Home  |   Forum  |   Wiki  |   Translate  |   Bugtracker  |   WebSVN  |  USVN

Time-Class

From EQdkp Plus Wiki

Contents

Introduction

The Time-Class is used to always display the correct date, also if users choose different timezones. When using the Time-Class you never need to care about timezones. (Except when you read timestamps directly from external sources).

Functions

Here is a list of available functions and what they expect as parameters and what they return.

setTimezone

With this function you set the usertimezone, so the timezone for the display of dates.

public function setTimezone(VALUE)
Name Description Example Values
VALUE The Timezone GMT, Europe/Berlin

__get

To fetch data from time-class such as serverTimezone, etc.

public function __get(KEY)
Possible Values Description
user_tz fetch user-timezone
gmt_tz get name of server-timezone
timezones get array of all timezones
time get actual time
minDate get minimum Date (e.g. for comparisons)
maxDate get maximum Date

mktime

returns timestamp, same behavior as php-function

public function mktime(HOUR='0', MIN='0', SEC='0', MONTH='0', DAY='0', YEAR='0')

date

returns formatted date, similar to php-function date, but obeys timezones.

public function date(FORMAT="Y-m-d H:i:s", TIMESTAMP='')

user_date

returns formatted date, simplifies using the date-format the user has set in his settings, obeys timezone

public function user_date(TIMESTAMP=false, WITHTIME=false, TIMEONLY=false, LONG=false)
Name Description Possible Values
TIMESTAMP The Timestamp false: returning '', 0 or '0' returning localized 'never', normal timestamp
WITHTIME Display Time false, true
TIMEONLY Display time only? false, true
LONG Display date in long-format false, true

fromformat

returns timestamp in servertimezone, expects formatted date from usertimezone as input.

public function fromformat(STRING, FORMAT=0)
Name Description Example Values
STRING The formatted date '19.04.2003 19:03'
FORMAT Format passing 0: format set to $user->data['user_date_short']
FORMAT Format passing 1: format set to $user->data['user_date_short'].' '.$user->data['user_date_time']
FORMAT Format passing a valid format: expects the given format as string ('d.m.y H:i')

translateformat2js

translate a php-valid date-format to a js-valid date format used in date and timepicker of jquery.

public function translateformat2js(FORMAT)