php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12681 php cannot convert dates to string and save it as (vchar) in Mysql
Submitted: 2001-08-09 17:59 UTC Modified: 2001-08-10 00:28 UTC
From: hatamy1 at aol dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.0.6 OS: Windows2000
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: hatamy1 at aol dot com
New email:
PHP Version: OS:

 

 [2001-08-09 17:59 UTC] hatamy1 at aol dot com
I have made it simple for you:

$day1=$date["mday"];
$mon1=$date["mon"];
$year1=$date["year"];
$date=$day1.".".$mon1.".".$year1;

$query="insert into data (coll) values ($date)";

ERROR!!!!
(try to change the Mysql col. attr. to date)
ERROR!!!!
-----------------------------------------------------
ok try it in an other way....

$pattern="/(\d{1,2})\.(\d{1,2})\.(\d{2,4})/";
if (preg_match($pattern,$heute,$regs)){
echo $regs[3],"-",$regs[2],"-",$regs[1];
$date=implode("-",$regs);

$query="insert into data (coll) values ($date)";

ERROR!!!!
(try to change the Mysql col. attr. to date)
ERROR!!!!

---------------------------------------------------
ok try it in an other way....

$mon1 = substr($str,5,2);
$day1 = substr($str,8,2);
$year1= substr($str,0,4);

$date=$day1.".".$mon1.".".$year1;

$query="insert into data (coll) values ($date)";

ERROR!!!!
(try to change the Mysql col. attr. to date)
ERROR!!!!
---------------------------------------------------
Summery: 
php does not return real strings back and only structures or pointers to structures which make the live of the programmers harder than it is!

My solution: please create a blody simple function to convert dates to strings ... somthing like:

$string=DateToStr($any_date_format);

Eventually I'm very sorry folks I find PHP very nice but
PHP cannot give any basic solutions for dates
which will force me to use Microsoft ASP 

Yeh!, it is slow but at least it works




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-10 00:28 UTC] cynic@php.net
The only error is your buggy code.

My solution: please don't waste developers' time with false, arrogant claims, and hire someone to fix bugs in your code. It's maybe slow but at least it works.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC