| | |
DATE problem
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2008
Posts: 43
Reputation:
Solved Threads: 0
I Need to insert a date into mysql database i dont know which is better
using DATE or VARCHAR as the date field ??
im using now the DATE type but whenever i insert any date its not inserted in the DB
0000-00-00 it appears like this .
the Code:
$mydate=date("$year.$month.$day");
insert into ....values ($mydate);
i dont know what's wrong
plz help
using DATE or VARCHAR as the date field ??
im using now the DATE type but whenever i insert any date its not inserted in the DB
0000-00-00 it appears like this .
the Code:
$mydate=date("$year.$month.$day");
insert into ....values ($mydate);
i dont know what's wrong
plz help
•
•
•
•
I Need to insert a date into mysql database i dont know which is better
using DATE or VARCHAR as the date field ??
im using now the DATE type but whenever i insert any date its not inserted in the DB
0000-00-00 it appears like this .
the Code:
$mydate=date("$year.$month.$day");
insert into ....values ($mydate);
i dont know what's wrong
plz help
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss
-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
•
•
Join Date: Jul 2004
Posts: 234
Reputation:
Solved Threads: 8
Replace dots with dashes. Try below.
php Syntax (Toggle Plain Text)
$mydate=date("$year-$month-$day");
•
•
Join Date: Oct 2007
Posts: 38
Reputation:
Solved Threads: 1
Regardless of what the error is I find it best to store a unix timestamp in the database in a "int" field and then use PHP to manipulate it.
This produces a very fast db table when sorting by date.
This is the best practice until you become more familiar with php and mysql and explore the differences in formatting the date.
To get the unix timestamp do something like:
you can then format this by doing:
Very simple.
This produces a very fast db table when sorting by date.
This is the best practice until you become more familiar with php and mysql and explore the differences in formatting the date.
To get the unix timestamp do something like:
PHP Syntax (Toggle Plain Text)
$unix_time = date('U');
PHP Syntax (Toggle Plain Text)
$formatted_time = date('Y-m-d',$unix_time); $formatted_time_plus_1_week = date('Y-m-d',strtotime("+1 week",$unix_time));
•
•
Join Date: Jul 2004
Posts: 234
Reputation:
Solved Threads: 8
php Syntax (Toggle Plain Text)
$date = '2008-09-29'; $newDate = date('d-m-Y', strtotime($date));
![]() |
Similar Threads
- date problem (Visual Basic 4 / 5 / 6)
- Small date problem (ASP)
- Dreamweaver MX2004 & date problem, etc. (Graphics and Multimedia)
- Access Date Problem (Computer Science)
- Hi Access Date Problem (> Now +7 Days And < Now +2 Months) (Computer Science)
- Date Problem (JSP)
Other Threads in the PHP Forum
- Previous Thread: How to retrieve .doc or .jpeg file from FTP server
- Next Thread: pliz help
Views: 714 | Replies: 9
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array autosuggest beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email emptydisplayvalue error explodefunction file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery keywords limit link login loop mail menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search searchbox select server sessions sms soap source space speed sql structure syntax system table tutorial update updates upload url validation validator variable video web xml youtube






