fsoftball
Apr 26 2005, 03:17 AM
| | Hi,
i have users entering a date as a text field. it is simply in ther form: "Apr 4".
since it is text, i cannot sort and the dates end up out of order. i am guessing that the best way to sort is to conveert it to an epoch and sort on that. is there a function to convert this text into a epoch date?
thanks. |
Reply
FaLgoR
Apr 26 2005, 04:41 PM
I don't know if is it what you want, but here we go  If you want to add the full date in somewhere, you'll have to use the function date. In this case, I think you must use date("r"); CODE <? echo date("r"); ?>
Put it wherever you want.
Reply
Newton
Apr 29 2005, 11:19 AM
You could use strtotime function present in php. You might have to format your string accordingly though. I haven't really worked with the function much but if you use a format such as, "10 April 2005", it'll give you the timestamp. Just play around with it for a bit and see what you come up with.
Reply
Spectre
May 24 2005, 03:08 AM
I'm not entirely sure what the form in question is for or exactly what fields exist, but it would probably be better to have three text fields - one for the month, the day, and the year (doesn't have to be in that order, obviously). Also remember to specify which is which. You could then parse the data knowing exactly how it should be formatted, and pass it to the mentioned strtotime() function.
Reply
beeseven
May 25 2005, 12:55 AM
Strtotime is very versitile. As long as you have a word for the month, it'll work with most formatting. But if your users don't know this, it would be easiest, as was already said, to use multiple inputs. Especially if you use a drop down box where possible.
Reply
Mike
May 25 2005, 10:47 AM
Are the people on your site posting things that makes them have to post the date of the their post. If so you could just add this to the post page: CODE
$time = date();
And you would insert '$time' into the date field instead of what the user would type, like '{$_POST['date']}'. Then where you would fetch the dates from the database to show them to everyone else, you would put this code: CODE
$query = mysql_query("SELECT date FROM db") or die(mysql_error()); $fetch = mysql_fetch_row($query); $gotit = $fetch[0]; $date = date('m-d-y g:i:s',$gotit);
Reply
Similar Topics
Keywords : dates
- Asking Girls Out On Dates
(15)
The Elder Scrolls Iv Oblivion
Release Dates (official ship date released!) (8) so..... how's everyone doing? ok? that's good, glad to hear it. so, um..... WHEN THE
HECK IS ELDER SCROLLS IV: OBLIVION COMING OUT?! *ahem* I heard it was march now. late
march... so, whatever happened to DECEMBER 30TH!??!?!?!! I wouldn't mind
the extra time if they were adding a mutiplayer or more maps, but no! apprently, they're
just tweaking. all fine and good. it's hard to work with new technology (can't wait for
radiant AI), but sheesh, it just keeps being pushed back everytime we get within a couple w....
Drop Down Lists Using Dates
(5) Hi, I have a page where the user enters a date. I would like to use drop down boxes for the date.
I would like the current date to be the default date. I think that part is pretty easy. However,
I am having trouble listing all of the months. It wills tart at July and end at December. I need
to list January through June. Anyone know a good way to list all the months? I am assuming that
I will be able to do the same sort of thing for the date. Thanks!....
Gt4 Online?
DATES PLEASE? (6) does anyone know if GT4 is going to have an online expansion, and if yes when? cuz grand tourismo is
the best realistic racing game and it needs ONLINE! i bought it for online play, i stuck it in,
and there wasnt any /ohmy.gif' border='0' style='vertical-align:middle' alt='ohmy.gif' /> i got
pissed and threw it havnt played it for a while, im waiting on online pack. or update. please inform
me?!....
Converting Dates
converting epoch to MM-DD-YYY (1) So this is probably a basic and lame question, but how can I convert dates so I can then sort them?
Right now, I have each part of a date as a separate variable: $month, $day, $year.
I'd like to store them in the database as epoch. This way when I do a query I can sort them by
date. I can figure out the datatype for the database later. I would also need to convert an epoch
to Month-Day-Year later on when I want to display this. I'm sure this isn't too complicated
but I figured asking for some suggestions anyway. Thanks!....
For Latest Reviews And Release Dates On Everything
www.flaminvibez.com (2) check out my new site that im finally done with. I still need to fix some stuff but its basically
done. please check it out and gimme some feedback. also plz register at the forums /smile.gif'
border='0' style='vertical-align:middle' alt='smile.gif' /> ....
Dates For Psp?
does anyone one the real date (1) is it ture that the PSP is out in the US on the 24/03/2005 and the uk have to wait till 24th june
/sad.gif' border='0' style='vertical-align:middle' alt='sad.gif' /> if thats so am buyin one from
US /biggrin.gif' border='0' style='vertical-align:middle' alt='biggrin.gif' /> can any help with
the dates if you know a date by the way am in the UK so if you have a date for the UK that would
be great cheers chris....
Looking for dates
|
*RANDOM STUFF*
*SIMILAR VIDEOS*
Searching Video's for dates
*MORE FROM TRAP17.COM*
|
advertisement
|
|