|
-
Jun 7th, 2003, 02:08 PM
#1
Thread Starter
Ya ya Baby!!!Me is Back
datetime (mysql) to array (php)
What I want to do is to take a datetime format information in my database and take the datetime from now and substract the datetime in ym database to know when the data was registered in my database.
My idea is to find a way to have the year,day,hour... seperated in some variable and do a substraction.
Question 1 :
Is there a way to do it without spliting all the data in some variable ( or an array) ?
Question 2: How I do to solve my problem? I cant figure out how.
Thx
-
Jun 7th, 2003, 10:30 PM
#2
Stuck in the 80s
You could try something like:
Code:
$date1 = date('Y-m-d', strtotime('2002-03-04'));
$date2 = date('Y-m-d', strtotime('2002-03-02'));
$a = strtotime($date1);
$b = strtotime($date2);
$diff = getdate(strtotime($date1) - strtotime($date2));
echo $diff['mday'];
Look up getdate() in the manual for more info.
-
Jun 8th, 2003, 12:44 PM
#3
Thread Starter
Ya ya Baby!!!Me is Back
Thx but I cant Insert data in my database when the data is : datetime format.
mysql:
name---------type
date_items datetime
code :
$sql = 'INSERT INTO market (id_items, price_items, date_items ) VALUES('.$id_w.', '.trim($price).', '.date("d-m-Y H:i:s").' )';
error:
Something is wrong in your syntax near of ' 2560, 08-06-2003 13:39:36 )'
-
Jun 8th, 2003, 01:58 PM
#4
Thread Starter
Ya ya Baby!!!Me is Back
Do I have to create in my database a format for my date?
-
Jun 8th, 2003, 04:18 PM
#5
Thread Starter
Ya ya Baby!!!Me is Back
I use timestamp and it work thx
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|