[PHP] Timestamps and strftime

2009-06-04 Thread John Comerford

Hi,

I am having a problem trying to use a date that I take from a MySQL 
database.  The field is defined as a timestamp in the database.  I 
extract it using PDO and I am trying to use the value with strftime as 
follows:


foreach ($stmt-fetchall(PDO::FETCH_ASSOC) as $row) {
 echo strftime(%j,$row['UpdateDate']);
}

but it returns the following error:

PHP Notice:  A non well formed numeric value encountered...

I understand that this is because strftime is expecting a numeric value 
and that ,$row['UpdateDate'] is a character but I am not sure how to 
resolve the issue.  Any help would be apprecaited.


TIA,
 JC


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



RE: [PHP] Timestamps and strftime

2009-06-04 Thread Mayer, Jonathan
Off the top of my head, would strtotime work?

ie

strftime(%j,strtotime($row['UpdateDate']))

-Original Message-
From: John Comerford [mailto:jo...@optionsystems.com.au] 
Sent: 04 June 2009 07:10
To: php-general@lists.php.net
Subject: [PHP] Timestamps and strftime

Hi,

I am having a problem trying to use a date that I take from a MySQL 
database.  The field is defined as a timestamp in the database.  I 
extract it using PDO and I am trying to use the value with strftime as 
follows:

foreach ($stmt-fetchall(PDO::FETCH_ASSOC) as $row) {
  echo strftime(%j,$row['UpdateDate']);
}

but it returns the following error:

PHP Notice:  A non well formed numeric value encountered...

I understand that this is because strftime is expecting a numeric value 
and that ,$row['UpdateDate'] is a character but I am not sure how to 
resolve the issue.  Any help would be apprecaited.

TIA,
  JC


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




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



Re: [PHP] Timestamps and strftime

2009-06-04 Thread John Comerford

Thanks Jonathan,

Thats exactly what I needed.

I appreciate the help,
 JC

Mayer, Jonathan wrote:

Off the top of my head, would strtotime work?

ie

strftime(%j,strtotime($row['UpdateDate']))

-Original Message-
From: John Comerford [mailto:jo...@optionsystems.com.au] 
Sent: 04 June 2009 07:10

To: php-general@lists.php.net
Subject: [PHP] Timestamps and strftime

Hi,

I am having a problem trying to use a date that I take from a MySQL 
database.  The field is defined as a timestamp in the database.  I 
extract it using PDO and I am trying to use the value with strftime as 
follows:


foreach ($stmt-fetchall(PDO::FETCH_ASSOC) as $row) {
  echo strftime(%j,$row['UpdateDate']);
}

but it returns the following error:

PHP Notice:  A non well formed numeric value encountered...

I understand that this is because strftime is expecting a numeric value 
and that ,$row['UpdateDate'] is a character but I am not sure how to 
resolve the issue.  Any help would be apprecaited.


TIA,
  JC


  



--
Option Systems Pty. Ltd.
53 Waverley Road, Malvern East, VIC 3145
PO Box 7, Caulfield East, VIC 3145
Phone: 03 9571 0100  Fax: 03 9571 0500

The information in this e-mail is confidential and is intended solely for the addressee. 
Any views or opinions presented are solely those of the author 
and do not necessarily represent those of Option Systems Pty.Ltd.

If you are not the intended recipient, please delete this message and
contact the sender.


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