RE: mysql timestamps

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sorry, the function is UNIX_TIMESTAMP(date). That will create a unix
timestamp from your date column. Use FROM_UNIXTIME() to create a MySQL
timestamp from a unix one. 

I'd recommend, though, that you just look up DATE_FORMAT() in the MySQL
manual and just use that.

http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html
#Date_and_time_functions

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/

> -----Original Message-----
> From: Paul Sharpe [mailto:Jesusdiscs@ntlworld.com]
> Sent: Monday, March 24, 2003 7:34 AM
> To: holmes072000@charter.net
> Subject: Re:  mysql timestamps
> 
> I hope you don't mind me bothering you like this but you seem to know
what
> you're talking about, you replied to my post on php.db in case you are
> wondering who the heck I am.
> 
> I tried the "SELECT TO_UNIXTIME(your_column) FROM table" command in
mysql,
> but i got an error returned
> "ERROR 1064: You have an error in your SQL syntax near '(date) FROM
news'
> at
> line 1"
> 
> I've tried putting a space between the TO_UNIXTIME and (date) <--the
name
> of
> my column  but still no avail
> 
> If you don't want me bothering you let me know
> 
> Any help would be genuinely appreciated
> 
> thanks
> Paul Sharpe
> ----- Original Message -----
> From: "John W. Holmes" <holmes072000@charter.net>
> To: "'Paul Sharpe'" <Jesusdiscs@ntlworld.com>; <php-db@lists.php.net>
> Sent: Monday, March 24, 2003 3:08 AM
> Subject: RE:  mysql timestamps
> 
> 
> > > how do i change the format of a MySQL timestamp (i.e hh:mm:ss
> > DD/MM/YYYY
> > > instead of YYYYMMDDhhmmss) retrieved from a mysql database with
php?
> >
> > Use
> >
> > SELECT TO_UNIXTIME(your_column) FROM table ...
> >
> > And then use date() in PHP to format the result to your liking.
> >
> > Or, you can use DATE_FORMAT() in your query to format the result to
your
> > liking.
> >
> > ---John W. Holmes...
> >
> > PHP Architect - A monthly magazine for PHP Professionals. Get your
copy
> > today. http://www.phparch.com/
> >
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux