Forum Moderators: coopster

Message Too Old, No Replies

date function

default date string is 0000-00-00 00:00:00

         

fenomen

7:16 pm on Nov 5, 2005 (gmt 0)

10+ Year Member



hi,

default date string is 0000-00-00 00:00:00 in my database. and i can add date("Y-n-j H:i:s"). it works.
but;
i use to call date .... echo date('j-n-y', $take['date']) .... this func. i want to take only j,n and y.

but when i call date with this string, it always gives me 1-1-97.
what is this problem?

(if i use only ...echo $take['date']..., it gives 2005-05-11 20:04:45.)

NomikOS

7:53 pm on Nov 5, 2005 (gmt 0)

10+ Year Member



I use int(11) for store dates i think is more easy their management.


echo date('format', $timestamp);

$timestamp must be an integer.
0000-00-00 00:00:00 is a string.

fenomen

1:14 pm on Nov 6, 2005 (gmt 0)

10+ Year Member



how i change it an integer?
or how i must save date my database?
and how i must call it?

NomikOS

3:29 pm on Nov 6, 2005 (gmt 0)

10+ Year Member



I tell you, use int (11) in database
0000-00-00 00:00:00 is a human readable format, not good for your computer!

date is given by time()

time() is the current unix timestamp; the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT). Can you believe it?
that is tasty for your computer.

use:
define('TIME_NOW', time());

or better
define('TIME_NOW', time() + $gmtDifferences);
considering the entire world

you obtain $gmtDifferences with javascript (auto) or setting by your users (manual: not reliable).

now let's type!

------------------------------------
consider: getdate(), date(), mktime(), time()
read the nanual!

mcibor

4:56 pm on Nov 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



However the main problem with your date format is that you use incorrect date strings.

To get 2005-11-06 you need date in format:

date("Y-m-d"), not j-n-Y

Michal Cibor