PHPackages                             yasanov/dater - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. yasanov/dater

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

yasanov/dater
=============

Compact PHP library for working with date/time in different formats &amp; timezones. Updated jstz

2.0.3.1(5y ago)019BSD-3-ClausePHPPHP &gt;=5.3.0

Since Mar 26Pushed 5y agoCompare

[ Source](https://github.com/yuAsanov/dater)[ Packagist](https://packagist.org/packages/yasanov/dater)[ Docs](https://github.com/barbushin/dater)[ RSS](/packages/yasanov-dater/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (7)Used By (0)

Dater
=====

[](#dater)

[![Author](https://camo.githubusercontent.com/f18fdab5c2556c2a0d2b9a31b5dd50f9fa32ff758343d74601b0a744cd12c6db/687474703a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d4062617262757368696e2d626c75652e7376673f7374796c653d666c61742d737175617265)](https://www.linkedin.com/in/barbushin)[![GitHub release](https://camo.githubusercontent.com/257f4b4ff77c1d432ed14bcc2c64f91d2839622aad041d55537008c588c11a39/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f62617262757368696e2f64617465722e7376673f6d61784167653d32353932303030267374796c653d666c61742d737175617265)](https://packagist.org/packages/dater/dater)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Packagist](https://camo.githubusercontent.com/cb33ae364eb63a722867f0d20872282157a87f76f719f8877168fd411e9b26dd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64617465722f64617465722e7376673f6d61784167653d3836343030267374796c653d666c61742d737175617265)](https://packagist.org/packages/dater/dater)

This library can be very helpful to standardize date-time formats in your project &amp; get done easy with different clients timezones.

Install
=======

[](#install)

The recommended way to install Dater is through [Composer](http://getcomposer.org). You can see [package information on Packagist.](https://packagist.org/packages/dater/dater)

```
{
	"require": {
		"yasanov/dater": "^2.0"
	}
}

```

Features
========

[](#features)

For all features using examples see [/example/index.php](https://github.com/barbushin/dater/blob/master/examples/index.php). PHP &gt; 5.3 required.

### Timestamp/datetime input formats support

[](#timestampdatetime-input-formats-support)

```
$dater = new Dater\Dater(new Dater\Locale\En());
echo $dater->datetime();
echo $dater->datetime(time());
echo $dater->datetime(date('Y-m-d H:i:s'));

```

### Formats binding

[](#formats-binding)

```
$dater->format(time(), 'd/m/Y'); // 2013/03/14
$dater->setFormat('slashedDate', 'd/m/Y');
$dater->format(time(), 'slashedDate'); // 2013/03/14
$dater->slashedDate(time()); // 2013/03/14

```

### Format options

[](#format-options)

All [date()](http://php.net/date) format options available and can be overrided or extended:

```
$dater->addFormatOption('ago', function (DateTime $datetime) {
	return floor((time() - $datetime->getTimestamp()) / 86400) . ' days ago';
});
$dater->format(time() - 60*60*24*7, 'd F Y, ago'); // 14 March 2013, 7 days ago

```

### Locales support

[](#locales-support)

```
$dater->setLocale(new Dater\Locale\En()); // or you can use Dater\Dater::getLocaleByCode('ru')
echo $dater->date(); // 03/21/2013
echo $dater->now('j F Y'); // 21 March 2013

$dater->setLocale(new Dater\Locale\Ru());
echo $dater->date(); // 21.03.2013
echo $dater->now('j F Y'); // 21 марта 2013

```

### Standard server &amp; user format methods

[](#standard-server--user-format-methods)

```
echo $dater->date(); // 03/21/2013 (client timezone, depends on locale)
echo $dater->time(); // 5:41 AM (client timezone, depends on locale)
echo $dater->datetime(); // 03/21/2013 5:41 (client timezone, depends on locale)
echo $dater->isoDate(); // 2013-03-21 (client timezone)
echo $dater->isoTime(); // 05:41:28 (client timezone)
echo $dater->isoDatetime(); // 2013-03-21 05:41:28 (client timezone)
echo $dater->serverDate(); // 2013-03-21 (server timezone)
echo $dater->serverTime(); // 09:41:28 (server timezone)
echo $dater->serverDatetime(); // 2013-03-21 09:41:28 (server timezone)

```

### Native PHP DateTime class object init &amp; formatting

[](#native-php-datetime-class-object-init--formatting)

```
$datetime = $dater->initDatetimeObject('2013-03-21 08:18:06', 'UTC', 'Europe/London');
$datetime->modify('+10 years');
echo $dater->formatDatetimeObject($datetime, 'date'); // 03/21/2013
// or same thing in one line with Dater\Dater :)
echo $dater->modify('2013-03-21 08:18:06', 'date', 'UTC', 'Europe/London'); // 03/21/2013

```

### Timezones conversion

[](#timezones-conversion)

```
$dater->setServerTimezone('Europe/Moscow');
$dater->setClientTimezone('Europe/London');
echo $dater->serverDatetime(); // 2013-03-21 08:18:06
echo $dater->isoDatetime(); // 2013-03-21 04:18:06
echo $dater->time(); // 04:18

```

### Timezone auto-detection

[](#timezone-auto-detection)

Based on JavaScript [jsTimezoneDetect](http://pellepim.bitbucket.org/jstz/) library with sending result to server by COOKIE.

```
$timezoneDetector = new Dater\TimezoneDetector();
echo '' . $timezoneDetector->getHtmlJsCode() .''; // ...
echo $timezoneDetector->getClientTimezone(); // Europe/London

```

### Convert request datetime to server timezone

[](#convert-request-datetime-to-server-timezone)

Is useful to auto-convert all client request datetime data to server timezone.

```
$_GET = array('filter' => array('startsFrom' => '2012-12-12 12:00:00'));
$_POST = array('event' => array('starts' => '2012-12-12 12:00:00'));
$_REQUEST = array_merge($_GET, $_POST);
$daterDataHandler = new Dater\DataHandler($dater);
$daterDataHandler->convertRequestDataToServerTimezone(); // all '2012-12-12 12:00:00' replaced to '2012-12-12 10:00:00'

```

### Convert text template datetime timezone

[](#convert-text-template-datetime-timezone)

Is useful to auto-convert all datetime in template date to client timezone. For example in Email template body.

```
$data = 'Timestamp format: 1363238564 (will not be handled)
Timestamp format: 1363238564[Y/m/d]
Timestamp format: 1363238564[datetime]
Server datetime format: 2013-03-14 09:22:44[Y/m/d]
Server datetime format: 2013-03-14 09:22:44[time]
Server datetime format: 2013-03-14 09:22:44';
echo $daterDataHandler->handleDataTimezone($data);

```

Will print:

```
Timestamp format: 1363238564 (will not be handled)
Timestamp format: 2013/03/14
Timestamp format: 14.03.2013 07:22
Server datetime format: 2013/03/14
Server datetime format: 07:22
Server datetime format: 2013-03-14 07:22:44

```

### Convert output datetime to client timezone

[](#convert-output-datetime-to-client-timezone)

```
$daterDataHandler->enableOutputTimezoneHandler();
echo $data; // $data from previous example will print the same as in prevous example

```

Recommended
-----------

[](#recommended)

- Google Chrome extension [PHP Console](http://goo.gl/b10YF)
- Google Chrome extension [JavaScript Errors Notifier](http://goo.gl/kNix9)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 83.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~556 days

Recently: every ~695 days

Total

6

Last Release

2011d ago

Major Versions

1.1.x-dev → 2.0.1RC12013-03-26

### Community

Maintainers

![](https://www.gravatar.com/avatar/2cd13fe2865dd6d1379a9e0b7fa6203a9ad721970f5f3559ba61165a49a2ab6d?d=identicon)[yasanov](/maintainers/yasanov)

---

Top Contributors

[![barbushin](https://avatars.githubusercontent.com/u/683352?v=4)](https://github.com/barbushin "barbushin (56 commits)")[![yuAsanov](https://avatars.githubusercontent.com/u/29858917?v=4)](https://github.com/yuAsanov "yuAsanov (4 commits)")[![felixmaier1989](https://avatars.githubusercontent.com/u/10077436?v=4)](https://github.com/felixmaier1989 "felixmaier1989 (3 commits)")[![dmromanov](https://avatars.githubusercontent.com/u/299059?v=4)](https://github.com/dmromanov "dmromanov (1 commits)")[![MuTaToR08](https://avatars.githubusercontent.com/u/8342939?v=4)](https://github.com/MuTaToR08 "MuTaToR08 (1 commits)")[![nehxby](https://avatars.githubusercontent.com/u/417439?v=4)](https://github.com/nehxby "nehxby (1 commits)")[![cmfcmf](https://avatars.githubusercontent.com/u/2145092?v=4)](https://github.com/cmfcmf "cmfcmf (1 commits)")

---

Tags

phpdatetimetimedatetimezone

### Embed Badge

![Health badge](/badges/yasanov-dater/health.svg)

```
[![Health](https://phpackages.com/badges/yasanov-dater/health.svg)](https://phpackages.com/packages/yasanov-dater)
```

###  Alternatives

[brick/date-time

Date and time library

3623.3M60](/packages/brick-date-time)[dater/dater

Compact PHP library for working with date/time in different formats &amp; timezones.

14282.3k](/packages/dater-dater)[kartik-v/php-date-formatter

A Javascript datetime formatting and manipulation library using PHP date-time formats.

461.5M3](/packages/kartik-v-php-date-formatter)[zjkal/time-helper

一个简单快捷的PHP日期时间助手类库。 a smart PHP datetime helper library.

21128.6k1](/packages/zjkal-time-helper)[fresh/datetime

PHP library that provides additional functions for processing dates &amp; times.

17513.8k2](/packages/fresh-datetime)[danielstjules/php-pretty-datetime

Generates human-readable strings for PHP DateTime objects

5791.9k](/packages/danielstjules-php-pretty-datetime)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
