php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #46383 Additional date/time functions
Submitted: 2008-10-24 23:15 UTC Modified: 2017-01-11 16:12 UTC
From: zoe at monkeehouse dot com Assigned:
Status: Wont fix Package: Date/time related
PHP Version: * OS: *
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2008-10-24 23:15 UTC] zoe at monkeehouse dot com
Description:
------------
Two PHP functions that replicate the MySQL functions of the same name.  These may be useful to other people given how popular the combination of PHP and MySQL is.

Reproduce code:
---------------
function time_to_sec($time) {
	$hours = substr($time, 0, -6);
	$minutes = substr($time, -5, 2);
	$seconds = substr($time, -2);

	return $hours * 3600 + $minutes * 60 + $seconds;
}

function sec_to_time($seconds) {
	$hours = floor($seconds / 3600);
	$minutes = floor($seconds % 3600 / 60);
	$seconds = $seconds % 60;

	return sprintf("%d:%02d:%02d", $hours, $minutes, $seconds);
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-02 01:59 UTC] jani@php.net
-Package: Feature/Change Request +Package: Date/time related -Operating System: +Operating System: * -PHP Version: 6CVS-2008-10-24 (CVS) +PHP Version: *
 [2017-01-11 16:12 UTC] heiglandreas@php.net
-Status: Open +Status: Wont fix
 [2017-01-11 16:12 UTC] heiglandreas@php.net
This issue is by now open for more than 8 years. And as the two functions can easily be created in userland I'm closing this.

Feel free to reopen should the need arise.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC