how to print 1965-05-09

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
hi there,

can anyone there teach me how to solve this?

my table - date field value return 1965-06-20, i want to display this
value in d-m-Y format.

how to print? now i only get it print as 01/01/1970 if the year<1970.

i know there is an adodb_date function. but then how can i convert
this value to time format as i also cannot use the strtotime function?
strtotime also return as -1. which also error.


thank you

Re: how to print 1965-05-09


Quoted text here. Click to load it

Why not let the database return the date in the format you like?

Quoted text here. Click to load it

That's the starting point of Unix timestamps. Some systems also allow
negative timestamps for dates <1970, but not all.


Re: how to print 1965-05-09

Quoted text here. Click to load it

There's good old sscanf() you can use:

sscanf($date, "%4d-%2d-%d", &$year, &$mon, &$day);

echo "$day/$mon/$year";

Re: how to print 1965-05-09 says...
Quoted text here. Click to load it

SQL has the solution.
Syntax may differ depending on the backend Database (Access over ODBC?)
but what you want is something like:

SELECT DATE_FORMAT('dd-mm-YYYY', DateField) AS 'Date' FROM items;

Lookup the DATE_FORMAT for exact values available in the format field.

Note of advice:
    Avoid confusing dates such as 02-01-01
    Jan 1st?  Feb 2nd?  2001? or 2002? ... 1902?

Particularly when producting any sort of information accessed by the
public, or many people, or used for historic references.

If you can, leave it in international format or use '01 Jan 2005', etc.

Treehouse Networks abuse@

Site Timeline