PHPackages                             uptime/uptime - 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. uptime/uptime

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

uptime/uptime
=============

Missing php uptime package inspired by python module uptime

0.2.0(9y ago)948.0k↓36.9%3[2 issues](https://github.com/marcioAlmada/uptime/issues)1MITPHPPHP &gt;=5.4.0

Since Aug 11Pushed 9y ago2 watchersCompare

[ Source](https://github.com/marcioAlmada/uptime)[ Packagist](https://packagist.org/packages/uptime/uptime)[ RSS](/packages/uptime-uptime/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (1)

Uptime - PHP
============

[](#uptime---php)

[![Build Status](https://camo.githubusercontent.com/b04c1b91ecc34d3392cf8f54e2fa47365a053c2857b3acb8f528381ea0ab1dbd/68747470733a2f2f7472617669732d63692e6f72672f6d617263696f416c6d6164612f757074696d652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/marcioAlmada/uptime)[![Coverage Status](https://camo.githubusercontent.com/9e8301780c074934b93d1d0be1cb0b2d6db2f64f90e21b61e9315b38b5a80aa1/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6d617263696f416c6d6164612f757074696d652f62616467652e706e67)](https://coveralls.io/r/marcioAlmada/uptime)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/74082d5ce6d1bd5994235bb5cb8bd8d9f6bc9b710584a2b27dbe74e9dc67e7b4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d617263696f416c6d6164612f757074696d652f6261646765732f7175616c6974792d73636f72652e706e673f733d33373639336336366535623733633061356531343830653030316362643039643035623736376237)](https://scrutinizer-ci.com/g/marcioAlmada/uptime/)[![Latest Stable Version](https://camo.githubusercontent.com/755633aaeec0de6a93ff4924d2616b386b7aa4abb0929f7c15e8c4b35794e95f/68747470733a2f2f706f7365722e707567782e6f72672f757074696d652f757074696d652f762f737461626c652e706e67)](https://packagist.org/packages/uptime/uptime)[![Total Downloads](https://camo.githubusercontent.com/2917f6ba5b877a2a6736f3e29b528205b229a9b566cd7d768e7847ca009260b9/68747470733a2f2f706f7365722e707567782e6f72672f757074696d652f757074696d652f646f776e6c6f6164732e706e67)](https://packagist.org/packages/uptime/uptime)[![License](https://camo.githubusercontent.com/7bb557fb34d0270d389bbacbb71c9ec950f4aaeca5db260c29ece56a6966c5f9/68747470733a2f2f706f7365722e707567782e6f72672f757074696d652f757074696d652f6c6963656e73652e706e67)](https://packagist.org/packages/uptime/uptime)

The missing PHP uptime package inspired by python module [uptime](https://pythonhosted.org/uptime/#module-uptime).

> This package aims to provides a **cross platform** PHP API — OO and functional — that tells you how long your system has been up and when it booted. This turns out to be surprisingly non-straightforward across systems, but not impossible on any major platform.

Supported Platforms
-------------------

[](#supported-platforms)

GroupSystems🆗BSD`FreeBSD`, `OpenBSD`, `NetBSD`, `BSD`🆗Linux`Linux`, `Cygwin`, `Linux-armv71`, `Linux2`, `Unix`, `SunOS`🆗Darwin`Darwin`, `Mac`, `OSX`🆗Windows`Windows`, `Win32`, `Winnt`🆗OpenVMS`OpenVMS`![:octocat:](https://github.githubassets.com/images/icons/emoji/octocat.png ":octocat:")NetWare`?`Composer Installation
---------------------

[](#composer-installation)

```
{
  "require": {
    "uptime/uptime": "~0.1"
  }
}
```

Through terminal: `composer require uptime/uptime:~0.1` 🎱

Quick Guide
-----------

[](#quick-guide)

Besides classes, this package registers two global functions: `uptime` and `boottime`.

```
$seconds   = uptime();   #  uptime in seconds
$timestamp = boottime(); #  server boottime timestamp
```

For more complex manipulations you can use the OO interface:

```
use Uptime\System;

$system = new System();           #

$uptime = $system->getUptime();   #  {}

$uptime->d                        #  days
$uptime->h                        #  hours
$uptime->m                        #  minutes
$uptime->s                        #  seconds

$boottime = $system->getBoottime(); #  {}
$boottime->format('Ymd H:i:s');    #  formatted date

echo 'Uptime: ' . $uptime . '. Boottime: ' . $boottime; # yes we have __toString
```

Uptime will guess your current OS by parsing [`PHP_OS`](http://www.php.net/manual/en/reserved.constants.php)constant value. In case you're using any exotic platform that is known to be compatible with one of the supported [systems](#supported-platforms), you can bypass OS detection by informing your system identifier manually (case insensitive):

```
$seconds   = uptime('JunOS');   #  server uptime in seconds
$timestamp = boottime('JunOS'); #  server boottime timestamp
```

You can bypass automatic system detection using the `Uptime\System` class too:

```
use Uptime\System;

$system = new System('JunOS'); #
$system = new System('Amiga'); # throws  {}
                               # patches welcome ;)
```

### Notes

[](#notes)

- Returned values will be as precise as your platform allows to, usually microseconds but it can be seconds;
- Some platforms need a better way to get uptime and boottime;
- For some platforms [`shell_exec`](http://www.php.net/manual/en/function.shell-exec.php) function needs to be enabled;

Extending Platform Support
--------------------------

[](#extending-platform-support)

1. Check `PHP_OS` constant value;
2. Map your platform or system identifier on [`Uptime\System\SystemTable::$map`](/src/System/SystemTable.php#L16);
3. Create a new runtime under `src/Runtime//*`, if necessary;
4. Add new tests to `test/Runtime//*`, if necessary;
5. Pull request;

Features &amp; Roadmap
----------------------

[](#features--roadmap)

- Functional API
- OO API
- Better cross platform tests
- Try to avoid child processes
- Maybe C extension

Copyright
---------

[](#copyright)

Copyright (c) 2014-\* Márcio Almada. Distributed under the terms of an MIT-style license. See LICENSE for details.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.4% 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 ~687 days

Total

2

Last Release

3610d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e6b4f6d6d37192719fb4d4d03bbdb9e866972a2b6556da9967b10b35843809f1?d=identicon)[marcioAlmada](/maintainers/marcioAlmada)

---

Top Contributors

[![marcioAlmada](https://avatars.githubusercontent.com/u/227395?v=4)](https://github.com/marcioAlmada "marcioAlmada (37 commits)")[![atilacamurca](https://avatars.githubusercontent.com/u/508624?v=4)](https://github.com/atilacamurca "atilacamurca (1 commits)")

---

Tags

systemuptimeboottime

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[pastuhov/php-exec-command

Simple php command executor with param binding.

25205.4k2](/packages/pastuhov-php-exec-command)

PHPackages © 2026

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