FW: Notice: A non well formed numeric value encountered

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

 



Hi again Stephen,

Further on my previous post, if you do store the UNIX timestamp as an
integer value, it should be very efficient, database storage and query
speed, plus giving you ease and flexibility in formatting via php.

-----Original Message-----
From: Naintara [mailto:naintara@xxxxxxxxxxxx] 
Sent: Saturday, September 22, 2007 10:19 PM
To: 'PHP-DB Mailing List'
Subject: RE:  Notice: A non well formed numeric value encountered

That's a good question. 

I'm really not sure about which way is better, but yes, you could use
UNIX_TIMESTAMP() to query a datetime value from a MySQL field, convert it
to the UNIX timestamp value within the query, and then retrieve it in your
record set. 
UNIX_TIMESTAMP() [MySQL function]

Or you could use php to convert a datetime value to UNIX timestamp.
mktime() [php function]

You could store the timestamp value in the database itself, and convert at
will in the program.
So many choices... I really wouldn't know which to recommend, a lot depends
on usage. The datetime column takes more storage than an integer column,
but it's human-readable.

If you mean storing an timestamp integer value in a particular database
field, that should also be fine. 

There are a whole lot of issues with datetime related functions, like DST
(daylight savings time) or timezones, if all that is critical, you may look
into it.
There is a TIMESTAMP field type in MySQL, the usage has changed in MySQL
4.1 and up.
This is useful for recording time/date of db updates.

For usual work, I find that a datetime data type column works for me.
Then, if I know what I will be using the datetime value for, I sometimes
format the date within the query itself using DATE_FORMAT() as I like to
get the results that way rather than change it, of course, if you may be
presenting the datetime value in different ways, or if you want the
flexibility, then use php.

I hope this helps somewhat.

-----Original Message-----
From: Stephen Sunderlin [mailto:stephen.sunderlin@xxxxxxxxxxx] 
Sent: Saturday, September 22, 2007 9:24 PM
To: 'Naintara'; 'PHP-DB Mailing List'
Subject: RE:  Notice: A non well formed numeric value encountered

Thank you for your response.

The notice is in the Subject Line of the email:
Notice: A non well formed numeric value encountered

So you are saying I have to convert the current yyyy-mm-dd:HH:MM:SS  date
format, to UNIX timestamp value then call Date() to format the UNIX
timestamp as Month, Day, Year?

If so, is it recommended to do that at the database level or the program
level.

I guess it would make sense to convert all dates to UNIX timestamp for
database storage then convert at necessary.

Any insight would be helpful.

Thanks!

-----Original Message-----
From: Naintara [mailto:naintara@xxxxxxxxxxxx] 
Sent: Saturday, September 22, 2007 11:13 AM
To: 'PHP-DB Mailing List'
Subject: RE:  Notice: A non well formed numeric value encountered

I don't see the NOTICE message.
Perhaps a timezone notice?

Lookup the date() function in the php manual.
The time parameter should be a unix timestamp value, so $CTS should contain
an integer value.
You can also find ways to convert the time value you have to unix
timestamp, in the manual.

-----Original Message-----
From: Stephen Sunderlin [mailto:stephen.sunderlin@xxxxxxxxxxx] 
Sent: Saturday, September 22, 2007 7:48 PM
To: 'PHP-DB Mailing List'
Subject:  Notice: A non well formed numeric value encountered

I'm getting the above NOTICE with the following statement:
Echo date('d/m/y',$CTS);

Where $CTS = 2007-09-22 10:09:31

And 31/12/69 is being echoed.


PHP 5.2.1
MYSQL 5.0.37-community-nt via tcp/ip

Thanks in advance for any insight.

-- 
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

-- 
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