RE: [PHP] date math question

2003-03-28 Thread John W. Holmes
This leads me to another question. If I have stored the date as an epoch then is there a way using PHP and MySQL to say find all the records that have been added this YEAR (not last 365 days)? SELECT * FROM table WHERE YEAR(FROM_UNIXTIME(column)) = YEAR(CUR_DATE()); Benchmark each method and

[PHP] date math question

2003-03-27 Thread Charles Kline
I am storing my dates as unix timestamp (epoch). Am I right in assuming that if I need to add or subtract days from this it is done in seconds? So for example if I have the timestamp 1041397200 and I wanted to subtract 24 hours from it I would do this: $newtime = $orig_time - 86400; Thanks,

Re: [PHP] date math question

2003-03-27 Thread Leo Spalteholz
On March 27, 2003 09:15 pm, Charles Kline wrote: I am storing my dates as unix timestamp (epoch). Am I right in assuming that if I need to add or subtract days from this it is done in seconds? yes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:

RE: [PHP] date math question

2003-03-27 Thread Martin Towell
I think there's problems doing that when daylight savings starts/ends Just something to keep in mind... -Original Message- From: Leo Spalteholz [mailto:[EMAIL PROTECTED] Sent: Friday, March 28, 2003 4:32 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] date math question On March 27, 2003 09

Re: [PHP] date math question

2003-03-27 Thread Charles Kline
Okay cool. This leads me to another question. If I have stored the date as an epoch then is there a way using PHP and MySQL to say find all the records that have been added this YEAR (not last 365 days)? Thanks Charles On Friday, March 28, 2003, at 12:31 AM, Leo Spalteholz wrote: On March 27,

Re: [PHP] date math question

2003-03-27 Thread Foong
hi, $start = mktime ( 0, 0, 0, 1, 1, date['Y']); // first day of this year $end = mktime ( 0, 0, 0, 12, 31, date['Y']); // last day of this year then select all record where timestamp = $start and timestamp = $end should do the job Hope this helps Foong Charles Kline [EMAIL PROTECTED]

Re: [PHP] date math question

2003-03-27 Thread Foong
sorry typo error should be: date('Y') Foong Foong [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] hi, $start = mktime ( 0, 0, 0, 1, 1, date['Y']); // first day of this year $end = mktime ( 0, 0, 0, 12, 31, date['Y']); // last day of this year then select all record where

Re: [PHP] date math question

2003-03-27 Thread Charles Kline
Caught that :) Thanks for the tip... worked just perfect (after I fixed typo) On Friday, March 28, 2003, at 12:57 AM, Foong wrote: sorry typo error should be: date('Y') Foong Foong [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] hi, $start = mktime ( 0, 0, 0, 1, 1, date['Y']); //