formatting date()
How do you reformat the date() string? I'm from the US, where we do month-day-year....so it's odd to see it as year-month-day...
anyways, how would i take a date("Y-m-d") and reformat it to be m-d-Y? Thanks
How do you reformat the date() string? I'm from the US, where we do month-day-year....so it's odd to see it as year-month-day...
anyways, how would i take a date("Y-m-d") and reformat it to be m-d-Y? Thanks
druagord posted this at 18:42 — 28th November 2003.
He has: 335 posts
Joined: May 2003
i guess you mean in php
<?php
$date_array = get_date();
echo $date_array['mon'].\"-\".$date_array['mday'].\"-\".$date_array['year'];
?>
you need a date other then today you can specify a timestamp as a parameter to get_date
IF , ELSE , WHILE isn't that what life is all about
Suzanne posted this at 20:52 — 28th November 2003.
She has: 5,507 posts
Joined: Feb 2000
I say you break with convention and teach your country-mates the right way to go...
druagord posted this at 21:01 — 28th November 2003.
He has: 335 posts
Joined: May 2003
I must admit US date format really is illogical
nike_guy_man posted this at 02:20 — 29th November 2003.
They have: 840 posts
Joined: Sep 2000
No, it makes sense...
Put all the #s at the end and all the big words in the beginning
November 28, 2003
See, makes sense
No need to change it, besides... who would listen?
Suzanne posted this at 02:36 — 29th November 2003.
She has: 5,507 posts
Joined: Feb 2000
lol, clearly you've not bumped into dates like 04/07/00 and had them interpreted as April 7th and July 4th, which can lead to an incredible contamination of the data.
kb posted this at 01:18 — 1st December 2003.
He has: 1,380 posts
Joined: Feb 2002
ok, but what if i'm pulling the data from a MySQL db?
Suzanne posted this at 01:39 — 1st December 2003.
She has: 5,507 posts
Joined: Feb 2000
A MySQL date setting in a database is in the YYYYMMDD HHMMSS format anyway. i.e. you can't put it into the database in any other format. (You can use YY:MM and such, but the order is always YYYYMMDD HHMMSS). To take input that isn't in the right format, see "STR_TO_DATE(str,format)" in the link below.
http://www.mysql.com/doc/en/Date_and_time_functions.html (scroll down or ctrl-f to "DATE_FORMAT(date,format)" for details on how to format it out of the database.)
The best idea is to provide educational assistance to your users or split the entry into year, month, day. For pulling it out, you can parse it as you wish and display it in any format.
Mark Hensler posted this at 09:50 — 1st December 2003.
He has: 4,048 posts
Joined: Aug 2000
If needed, you may also read about setlocale() (I've never used it).
kb posted this at 21:39 — 2nd December 2003.
He has: 1,380 posts
Joined: Feb 2002
thanks!
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.