php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #61987 abbreviate "Y-m-d H:i:s" to Q
Submitted: 2012-05-10 04:51 UTC Modified: 2017-01-13 07:02 UTC
Votes:8
Avg. Score:3.6 ± 1.7
Reproduced:5 of 7 (71.4%)
Same Version:3 (60.0%)
Same OS:3 (60.0%)
From: mark at skimbl dot com Assigned:
Status: Wont fix Package: Date/time related
PHP Version: Irrelevant OS: N/A
Private report: No CVE-ID: None
 [2012-05-10 04:51 UTC] mark at skimbl dot com
Description:
------------
---
From manual page: http://www.php.net/function.date
---
Is there any chance the common Y-m-d H:i:s can be summarized as "Q" for the common MySQL datetime format. I have written this sequence hundreds of times (You're the man now dog, Hamlet in space?)
Seeing as MySQL and PHP are so commonly tied together I think this could be a very useful shortcut to add.

http://stackoverflow.com/search?q=Y-m-d+H%3Ai%3As over 5.000 related issues
https://www.google.com/search?q=%22Y-m-d+H%3Ai%3As%22 over 1.7 million results
Easier and quicker to memorize.


Test script:
---------------
<?php 
echo date('Q'); // Prints Q

Expected result:
----------------
2012-05-10 12:00:00


Patches

php_data.patch (last revision 2012-05-14 14:51 UTC by zhanglijiu at gmail dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-05-19 16:50 UTC] joergybehrens at gmail dot com
Hi mark: You could add the function by yourself. Boz the new feature could affect 
other parameter of Data() function. And the patch you could try for your own 
version PHP.
 [2012-05-20 00:22 UTC] zhanglijiu at gmail dot com
@joergybehrens I checked the parameter Q, which is not the key word of parameter. 
It can be used for the function. But the problem is personal problem, which is 
difficult to be pulled in git.
 [2017-01-13 07:02 UTC] heiglandreas@php.net
-Status: Open +Status: Wont fix
 [2017-01-13 07:02 UTC] heiglandreas@php.net
This is already existent. You can format a date using 'c' and insert that into a DATETIME-field in MySQL. The Offset is ignored. 

If you insert "2004-02-12T15:19:21+04:00" it will show up on the database as "2004-02-12 15:19:21". So make sure the datetimes you are inserting all have the same offset.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC