Page 1 of 1

Access2000 + PHP4 date format

Posted: Sun Aug 25, 2002 7:00 am
by Jochen_DE
Hello...

I created a table with MS ACCESS2000.
THis table contains a date/time field with the format dd.mm.yyyy.

When I connect to the databse with PHP and load this field/column, I get the date displayed in "yyyy-mm-dd hh:mm:ss"...

How do I fix this???

Greets,
Jochen

Posted: Mon Aug 26, 2002 5:35 am
by mikeq
Have a look at the date functions in the PHP manual.

http://www.php.net/

Posted: Tue Aug 27, 2002 10:07 am
by Jochen_DE
I did...
I can load the correct date.
But I can't load it from the database...

From the database, the date comes like "yyyy-mm-dd hh:mm:ss"...

When I want the date with PHP is use date("d.m.Y") and get "dd.mm.yyyy"...

Why does that not work with my database??

Jochen

Posted: Wed Aug 28, 2002 1:47 am
by twigletmac
What does the code look like that you are trying to format the date with?

Mac

Posted: Wed Aug 28, 2002 2:04 am
by Jochen_DE
At the moment, I'm not formatting the date comming from the database...

That was my question - how do I transform the date that I can compare it with another date?

Database-date: 'yyyy-mm-dd hh:mm:ss'
date to compare with: 'dd.mm.yy'

Date to be displayed: 'dd.mm.yy'

Greets,
Jochen

Posted: Wed Aug 28, 2002 2:18 am
by twigletmac
Ok, now you've actually stated your question. I could tell you how to do this in MySQL since that's nice and easy but I have no idea if Access 2000 does things in the same way - try looking in the help text for DATE_FORMAT.

But since you're using MS Access (you should consider changing you know :wink: ) and having actually looked at the date and time functions in PHP (and edited away my former very hacky solution):

Code: Select all

<?php 
$date_from_database = '2002-01-03';
$db_date = strtotime($date_from_database);
$db_date = date('d.m.y', $db_date);
echo $db_date; 
?>
Mac

Posted: Wed Aug 28, 2002 2:20 am
by hob_goblin