PHPackages                             michaelesmith/datetime - 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. michaelesmith/datetime

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

michaelesmith/datetime
======================

Extends PHP's DateTime class with convenience methods

2119[1 issues](https://github.com/michaelesmith/msDateTime/issues)PHP

Since Aug 3Pushed 11y ago1 watchersCompare

[ Source](https://github.com/michaelesmith/msDateTime)[ Packagist](https://packagist.org/packages/michaelesmith/datetime)[ RSS](/packages/michaelesmith-datetime/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (2)Used By (0)

[![Build Status](https://camo.githubusercontent.com/eea7df47783596cd45337b6e001cb3599ca96b51a44e5d83f25b04f589cc68e1/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f6d69636861656c65736d6974682f6d734461746554696d652e706e67)](http://secure.travis-ci.org/michaelesmith/msDateTime)[![SensioLabsInsight](https://camo.githubusercontent.com/c5464238d2d225f716af2640e0b47657b3e423bd6e45140db1b5f4751befe452/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f31313866643136322d346233362d346261342d393735662d3133323463343532333163312f6d696e692e706e67)](https://insight.sensiolabs.com/projects/118fd162-4b36-4ba4-975f-1324c45231c1)

README
======

[](#readme)

What is msDateTime?
-------------------

[](#what-is-msdatetime)

An extension of the PHP native DateTime object to provide powerful convenience methods.

Installation
------------

[](#installation)

### Use Composer (*recommended*)

[](#use-composer-recommended)

The recommended way to install msDateTime is through composer.

If you don't have Composer yet, download it following the instructions on  or just run the following command:

```
curl -s http://getcomposer.org/installer | php

```

Just create a `composer.json` file for your project:

```
{
    "require": {
        "michaelesmith/datetime": "*"
    }
}
```

For more info on composer see

Examples
--------

[](#examples)

\###Basic

```
$d = new msDateTime('2/5/1980 18:53:37'); //any string you could use with php's native DateTime
var_dump($d->format('l F j @ g:ia')); //any formating accepted by php's date()
// string(27) "Tuesday February 5 @ 6:53pm"
var_dump($d->dump()); //show current timestamp human readable for debugging
// string(31) "Tue, 05 Feb 1980 18:53:37 -0600"

```

\###Convenience methods example

```
$d = new msDateTime();
var_dump($d->modify('-1 year +3 days')->dump());
// string(31) "Thu, 19 Aug 2010 22:38:39 -0500"
var_dump($d->finalDayOfQuarter()->endOfDay()->dump());
// string(31) "Thu, 30 Sep 2010 23:59:59 -0500"
var_dump($d->reset()->dump()); //internal timestamp can be reset to initial
// string(31) "Tue, 16 Aug 2011 22:38:39 -0500"

```

Complete list of methods
------------------------

[](#complete-list-of-methods)

\###Update

- public function beginningOfDay()
- public function endOfDay()
- public function firstDayOfWeek() //Sets to Sunday
- public function finalDayOfWeek() //Sets to Saturday
- public function firstDayOfMonth()
- public function finalDayOfMonth()
- public function firstDayOfQuarter()
- public function finalDayOfQuarter()
- public function isFinalDayOfQuarter()

\###Tests

- public function isBeginningOfDay()
- public function isEndOfDay()
- public function isFirstDayOfWeek() //Returns true for Sunday
- public function isFinalDayOfWeek() //Returns true for Saturday
- public function isFirstDayOfMonth()
- public function isFinalDayOfMonth()
- public function isFirstDayOfQuarter()

\###Tests around now

- public function isToday()
- public function isTomorrow()
- public function isYesterday()
- public function isCurrentWeek() //Uses ISO-8601 weeks Monday - Sunday
- public function isCurrentMonth()
- public function isCurrentYear()

\###Miscellaneous

- public static function create($time = null, $object = null) //Creates a new msDateTime object inline to preserve fluid calls
- public function \_\_toString() //Returns the current timestamp in "Y-m-d H:i:s" format
- public function copy()
- public function compare($msDateTime2) //Compares this object to $msDateTime2 by returning the difference in seconds
- public function dump() //Outputs the current timestamp in a general format. Should only be used for debugging.
- public function getQuarter()

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/181546?v=4)[Michael Smith](/maintainers/michaelesmith)[@michaelesmith](https://github.com/michaelesmith)

---

Top Contributors

[![michaelesmith](https://avatars.githubusercontent.com/u/181546?v=4)](https://github.com/michaelesmith "michaelesmith (38 commits)")

### Embed Badge

![Health badge](/badges/michaelesmith-datetime/health.svg)

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

###  Alternatives

[pyrech/composer-changelogs

Display changelogs after each composer update

5904.0M25](/packages/pyrech-composer-changelogs)[coenjacobs/mozart

Composes all dependencies as a package inside a WordPress plugin

4723.6M20](/packages/coenjacobs-mozart)[ecotone/ecotone

Supporting you in building DDD, CQRS, Event Sourcing applications with ease.

558549.8k17](/packages/ecotone-ecotone)[geocoder-php/plugin

Plugins to Geocoder providers

705.1M2](/packages/geocoder-php-plugin)[verbb/comments

Add comments to your site.

13753.1k](/packages/verbb-comments)[pocketmine/bedrock-block-upgrade-schema

Schemas describing how to upgrade saved block data in older Minecraft: Bedrock Edition world saves

23355.4k5](/packages/pocketmine-bedrock-block-upgrade-schema)

PHPackages © 2026

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