Mailinglisten-Archive |
Hi Uli,
Ich verwende dafuer den Datentyp datetime, man kann jedoch auch nur date
verwenden. Das einfuegen des aktuellen Datums ist einfach:
INSERT INTO st VALUES (now());
:-) Das now() macht die ganze Arbeit. Fuer abweichende Eintragungen braucht
man nur das Standardformat einhalten, IMO 'yyyy-mm-dd hh:mm:ss'
Datumsfunktionen sind in der MySQL Hilfe dokumentiert:
DATE_FORMAT(Date, Format)
Formats the Date (a date or a timestamp) according to the Format string.
The following format commands are known:
M Month name
W Weekday name
D Day of the month with english suffix
Y Year with 4 digits
y Year with 2 digits
a Abbreviated weekday name (Sun..Sat)
d Day of the month, numeric
m Month, numeric
b Abbreviated month name (Jan.Dec)
j Day of year (001..366)
H Hour (00..23)
k Hour ( 0..23)
h Hour (01..12)
I Hour (01..12)
l Hour ( 1..12)
i Minutes, numeric
r Time, 12-hour (hh:mm:ss [AP]M)
T Time, 24-hour (hh:mm:ss)
S Seconds (00..59)
s Seconds (00..59)
p AM or PM
w Day of the week (0=Sunday..)
Also zum Beispiel:
mysql_db_query("test","SELECT *,DATE_FORMAT(datum,'d.m.Y') as ddatum FROM
...
Mit freundlichen Gruessen
Ralf Ebert
php::bar PHP Wiki - Listenarchive