Re: Re: days of the week, time calculations

From: Date: Sat, 08 Jul 2000 22:20:10 +0000
Subject: Re: Re: days of the week, time calculations
Groups: php.db 
Request: Send a blank email to php-db+get-980@lists.php.net to get a copy of this message
Addressed to: Egon Schmid <eschmid@php.net> Kenn Murrah <kwmurrah@myfavoritei.com> php-db@lists.php.net ** Reply to note from Egon Schmid <eschmid@php.net> Sat, 08 Jul 2000 16:26:13 +0200 > > Kenn Murrah wrote: > > > I need to convert MySQL's timestamp into a format > > that I can use for calculating the number of seconds > > between two date/times. I also need to be able to > > determine what day of the week a given timestamp > > is. > > > > I've looked everywhere that I can think of to look -- can > > anyone point me in the right direction? > > http://zend.com/manual/ref.datetime.php and look for date() and > mktime(). > I would suggest you look in the MySQL manual for ways to format MySQL date/time/timestamp fields: http://www.mysql.com/documentation/mysql/commented/manual.php?sectio n=Date_and_time_functions You may have to re-format the URL go make it fit on one line... Some interesting topics from that URL: DAYOFWEEK(date) Returns the weekday index for date (1 = Sunday, 2 = Monday, ... 7 = Saturday). These index values correspond to the ODBC standard. mysql> select DAYOFWEEK('1998-02-03'); -> 3 WEEKDAY(date) Returns the weekday index for date (0 = Monday, 1 = Tuesday, ... 6 = Sunday). mysql> select WEEKDAY('1997-10-04 22:23:00'); -> 5 mysql> select WEEKDAY('1997-11-05'); UNIX_TIMESTAMP() UNIX_TIMESTAMP(date) If called with no argument, returns a Unix timestamp (seconds since '1970-01-01 00:00:00' GMT). If UNIX_TIMESTAMP() is called with a date argument, it returns the value of the argument as seconds since '1970-01-01 00:00:00' GMT. date may be a DATE string, a DATETIME string, a TIMESTAMP, or a number in the format YYMMDD or YYYYMMDD in local time. mysql> select UNIX_TIMESTAMP(); -> 882226357 mysql> select UNIX_TIMESTAMP('1997-10-04 22:23:00'); -> 875996580 When UNIX_TIMESTAMP is used on a TIMESTAMP column, the function will receive the value directly, with no implicit ``string-to-unix-timestamp'' conversion. Rick Widmer Internet Marketing Specialists www.developersdesk.com

« previous php.db (#980) next »