RE: [PHP] Date & Time Formatting ??
On 08-May-01 Jack Sasportas wrote: > > The Goal is to have the Time stamp looking like 12:24 (military time OK) > > and the date 05-08-2001 or even 05-08-01. > > The MySQL db looks like so: > date -00-00 > time 00:00:00 > > I don't seem to really be able to vary the DB format. combine the date & time: mystamp datetime .. select date_format(mystamp,'%m-%d%Y %r') as ts from blah; > > Any examples or links to good docs appreciated find /usr/local -name "manual.txt" -print | grep mysql http://www.mysql.com/manual.php Regards, -- Don Read [EMAIL PROTECTED] -- It's always darkest before the dawn. So if you are going to steal the neighbor's newspaper, that's the time to do it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Date & Time Formatting ??
Are you *absolutely sure* that mysql_result($db_result, $dbrecord, 'date') contains a UNIX timestamp? IOW, if I inserted the lines: $unixdate = mysql_result($db_result,$db_record,'date'); echo $unixdate; I would see something like "989393400" on the screen? (Speaking from experience, I got this hugely messed up first time round... search for one of my posts a few months ago where I was passing a string to the date function if you fancy a chuckle) Cheers Jon -Original Message- From: Jack Sasportas [mailto:[EMAIL PROTECTED]] Sent: 08 May 2001 17:46 To: php Subject: Re: [PHP] Date & Time Formatting ?? Here is what I am trying to do, but I get the wrong date: $t_data_array[1]=date("m/d/y",mysql_result($db_result,$db_record,'date')); Then I simply print the value in the arraythis date instead of 05/08/01 comes out 12/31/69 Thanks! Jon Haworth wrote: > I think the best way to handle this is not to care what it looks like in the > database. Store your dates as UNIX timestamps, and then they are easy to do > calculations on and/or convert to any date format you like for displaying in > your pages. > > Read up on date() and mktime() for more info (there are loads of examples in > the user notes). > > HTH > Jon ** 'The information included in this Email is of a confidential nature and is intended only for the addressee. If you are not the intended addressee, any disclosure, copying or distribution by you is prohibited and may be unlawful. Disclosure to any party other than the addressee, whether inadvertent or otherwise is not intended to waive privilege or confidentiality' ** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Date & Time Formatting ??
Here is what I am trying to do, but I get the wrong date: $t_data_array[1]=date("m/d/y",mysql_result($db_result,$db_record,'date')); Then I simply print the value in the arraythis date instead of 05/08/01 comes out 12/31/69 Thanks! Jon Haworth wrote: > I think the best way to handle this is not to care what it looks like in the > database. Store your dates as UNIX timestamps, and then they are easy to do > calculations on and/or convert to any date format you like for displaying in > your pages. > > Read up on date() and mktime() for more info (there are loads of examples in > the user notes). > > HTH > Jon > > -Original Message- > From: Jack Sasportas [mailto:[EMAIL PROTECTED]] > Sent: 08 May 2001 17:28 > To: php > Subject: [PHP] Date & Time Formatting ?? > > OK I have read many examples, old posts etc, but I am looking for a > detailed explanation as to how to do this. > > First is when I write to a mysql database using the now() function, the > time stamp looks like so when I display the time back to the browser. > > 204:24:06 ( This should have been 12:24pm ) > > Also the Date Display like so: > > 2001-05-08 > > The Goal is to have the Time stamp looking like 12:24 (military time OK) > > and the date 05-08-2001 or even 05-08-01. > > The MySQL db looks like so: > date -00-00 > time 00:00:00 > > I don't seem to really be able to vary the DB format. > > Any examples or links to good docs appreciated > Thanks... > > ** > 'The information included in this Email is of a confidential nature and is > intended only for the addressee. If you are not the intended addressee, > any disclosure, copying or distribution by you is prohibited and may be > unlawful. Disclosure to any party other than the addressee, whether > inadvertent or otherwise is not intended to waive privilege or confidentiality' > > ** > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- ___ Jack Sasportas Innovative Internet Solutions Phone 305.665.2500 Fax 305.665.2551 www.innovativeinternet.com www.web56.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Date & Time Formatting ??
I think the best way to handle this is not to care what it looks like in the database. Store your dates as UNIX timestamps, and then they are easy to do calculations on and/or convert to any date format you like for displaying in your pages. Read up on date() and mktime() for more info (there are loads of examples in the user notes). HTH Jon -Original Message- From: Jack Sasportas [mailto:[EMAIL PROTECTED]] Sent: 08 May 2001 17:28 To: php Subject: [PHP] Date & Time Formatting ?? OK I have read many examples, old posts etc, but I am looking for a detailed explanation as to how to do this. First is when I write to a mysql database using the now() function, the time stamp looks like so when I display the time back to the browser. 204:24:06 ( This should have been 12:24pm ) Also the Date Display like so: 2001-05-08 The Goal is to have the Time stamp looking like 12:24 (military time OK) and the date 05-08-2001 or even 05-08-01. The MySQL db looks like so: date -00-00 time 00:00:00 I don't seem to really be able to vary the DB format. Any examples or links to good docs appreciated Thanks... ** 'The information included in this Email is of a confidential nature and is intended only for the addressee. If you are not the intended addressee, any disclosure, copying or distribution by you is prohibited and may be unlawful. Disclosure to any party other than the addressee, whether inadvertent or otherwise is not intended to waive privilege or confidentiality' ** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Date & Time Formatting ??
OK I have read many examples, old posts etc, but I am looking for a detailed explanation as to how to do this. First is when I write to a mysql database using the now() function, the time stamp looks like so when I display the time back to the browser. 204:24:06 ( This should have been 12:24pm ) Also the Date Display like so: 2001-05-08 The Goal is to have the Time stamp looking like 12:24 (military time OK) and the date 05-08-2001 or even 05-08-01. The MySQL db looks like so: date -00-00 time 00:00:00 I don't seem to really be able to vary the DB format. Any examples or links to good docs appreciated Thanks... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Date/Time Formatting
When you are doing you select try something more along the lines of: select date_format(date, '%e,%c,%Y') from tblmycoolstuff; I got most of this stuff from http://www.mysql.com/doc/D/a/Date_and_time_functions.html You need to look at the table on that page to get the date to print out exactly as you want it. I know date_format works with the timestamp column type, but I don't know (but I assume) that it works the same exact way for some of the other types that store dates :-) If you still are having trouble, maybe I could help you? Jeff ""Richard Lynch"" <[EMAIL PROTECTED]> wrote in message 01e801c08244$85dfd640$[EMAIL PROTECTED]">news:01e801c08244$85dfd640$[EMAIL PROTECTED]... > > Also I'd like to if possible to be able to enter and display the date in > > Australian / European Time format (DD,MM,) > > I'm currently entering it on the form using three text fields and then > > rearanging them to the Format in mySQL and indserting it as a string, but > I > > don't know how to 'break' up a mySQL Date value to rearange it. > > The breaking up of a MySQL date would be in the MySQL manual at > http://mysql.org > I dunno what it's called... In PostgreSQL it's "date_part" though :-) > > I'm afraid there was another question in there somewhere, but I couldn't > really discern it -- What you are doing seems quite reasonable to me. > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Date/Time Formatting
> Also I'd like to if possible to be able to enter and display the date in > Australian / European Time format (DD,MM,) > I'm currently entering it on the form using three text fields and then > rearanging them to the Format in mySQL and indserting it as a string, but I > don't know how to 'break' up a mySQL Date value to rearange it. The breaking up of a MySQL date would be in the MySQL manual at http://mysql.org I dunno what it's called... In PostgreSQL it's "date_part" though :-) I'm afraid there was another question in there somewhere, but I couldn't really discern it -- What you are doing seems quite reasonable to me. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Date/Time Formatting
On Fri, 19 Jan 2001, Jamie wrote: > I'm fairly new to SQL and PHP and I'm haveing trouble useing the Date > functions of Both Systems, so I'd be greatfull if someone can help. > What I'm trying to do is have an 'administrator' be able to enter info > through a form to a mySQL database. Then on a seperate page have the info > reread and displayed. The basic outline is a News page which reads and > displays from the table and shows the News topics preceeding and inculding > the current date (ie if I enter a future Date eg 25/12/2001 and the comment > Merry christmas, in the databaes I don't want it to appear until the date > has occured) > > The Table looks as follows: > CREATE TABLE news ( > news_id INT NOT NULL primary key auto_increment, > topic VARCHAR(30) NOT NULL, > live_date dateNOT NULL, > news BLOBNOT NULL, > user_id VARCHAR(20) NOT NULL); > > I've used the MYSQL date type as I think this would be easier for the users > to be able to manually enter the date in is form on the admin form - also I > don't think a more accurate date/time method will be more usful. > > Currently I'm using this SQL Line: > SELECT * FROM news ORDER BY live_date DESC LIMIT 4 > (where Live_Date is the date to display the news after) > > Also I'd like to if possible to be able to enter and display the date in > Australian / European Time format (DD,MM,) > I'm currently entering it on the form using three text fields and then > rearanging them to the Format in mySQL and indserting it as a string, but I > don't know how to 'break' up a mySQL Date value to rearange it. > > Hope these arn't in the FAQ as I have spent some time looking through PHP > script sites and have been unable to find anything that can help. > The reason you haven't found anything on PHP sites is that they're not PHP questions, they're MySQL questions :) For the future date, add "live_date<=NOW()" to your WHERE clause in your select queries. As for the date format, MySQL only supports ANSI format (-MM-DD) for input, but you can use the DATE_FORMAT() function to change the output. You'll have to use substr() in PHP to chop up the input string and rearrange it for MySQL. -- Ignacio Vazquez-Abrams <[EMAIL PROTECTED]> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Date/Time Formatting
I'm fairly new to SQL and PHP and I'm haveing trouble useing the Date functions of Both Systems, so I'd be greatfull if someone can help. What I'm trying to do is have an 'administrator' be able to enter info through a form to a mySQL database. Then on a seperate page have the info reread and displayed. The basic outline is a News page which reads and displays from the table and shows the News topics preceeding and inculding the current date (ie if I enter a future Date eg 25/12/2001 and the comment Merry christmas, in the databaes I don't want it to appear until the date has occured) The Table looks as follows: CREATE TABLE news ( news_id INT NOT NULL primary key auto_increment, topic VARCHAR(30) NOT NULL, live_date dateNOT NULL, news BLOBNOT NULL, user_id VARCHAR(20) NOT NULL); I've used the MYSQL date type as I think this would be easier for the users to be able to manually enter the date in is form on the admin form - also I don't think a more accurate date/time method will be more usful. Currently I'm using this SQL Line: SELECT * FROM news ORDER BY live_date DESC LIMIT 4 (where Live_Date is the date to display the news after) Also I'd like to if possible to be able to enter and display the date in Australian / European Time format (DD,MM,) I'm currently entering it on the form using three text fields and then rearanging them to the Format in mySQL and indserting it as a string, but I don't know how to 'break' up a mySQL Date value to rearange it. Hope these arn't in the FAQ as I have spent some time looking through PHP script sites and have been unable to find anything that can help.