RE: [PHP-DB] Date problem: data is current as of yesterday

2004-07-03 Thread Ford, Mike [LSS]
-Original Message-
From: Karen Resplendo
To: [EMAIL PROTECTED]
Sent: 02/07/04 19:36
Subject: [PHP-DB] Date problem: data is current as of yesterday

The database queries all the sources at night after everyone has gone
home. That means the data was current as of yesterday. This little
snippet below returns yesterday's date, except that the first day of the
month returns 0 for the day. Now, I know why this is happening, but I
can't find out how to fix it (in VBA or SQL Server I would just say,
date()-1:
 
$today = getdate(); 
$month = $today['month'] ; 
$mday = $today['mday'] -1; 
$year = $today['year']; 
echo Data is current  as of  b$month $mday, $year/bbr;

--

The mktime() function is your friend for this kind of date arithmetic. For
example, this is one possible way to do what you want:

  $yesterday = mktime(12, 0, 0, $today['mon'], $today['mday']-1,
$today['year']);
  echo Data is current as of b.date(F j, Y, $yesterday);

(Note the use of time 12:00:00 to avoid daylight savings oddities!)

The examples on the date() and mktime() manual pages may suggest other
possibilities to you.

Cheers!

Mike
 


-
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!

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



[PHP-DB] Date problem: data is current as of yesterday

2004-07-02 Thread Karen Resplendo
The database queries all the sources at night after everyone has gone home. That means 
the data was current as of yesterday. This little snippet below returns yesterday's 
date, except that the first day of the month returns 0 for the day. Now, I know why 
this is happening, but I can't find out how to fix it (in VBA or SQL Server I would 
just say, date()-1:
 
$today = getdate(); 
$month = $today['month'] ; 
$mday = $today['mday'] -1; 
$year = $today['year']; 
echo Data is current  as of  b$month $mday, $year/bbr;
 
 


-
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!

Re: [PHP-DB] Date problem: data is current as of yesterday

2004-07-02 Thread jeffrey_n_Dyke


accidentally replied only to karen.

 The database queries all the sources at night after everyone has gone
home. That means the data was current as of yesterday. This little snippet
below returns yesterday's date, except that the first day of the month
returns 0 for  the day. Now, I know why this is happening, but I can't
find out how to fix it (in VBA or SQL Server I would just  say,
date()-1:

 $today = getdate();
 $month = $today['month'] ;
 $mday = $today['mday'] -1;
 $year = $today['year'];
 echo Data is current  as of  b$month $mday, $year/bbr;

you can do the same thing with php.

I'd use a timestamp and subtract 86400 (24 hours of seconds)

$yesterday_at_this_time = date(Y-m-d H:i:s, time() - 86400);

hth
Jeff
-
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!

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