Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Problems? Is your data what you think it is?
 
PerlMonks  

Re^3: Timestamp problem

by Tomte (Priest)
on May 16, 2007 at 09:14 UTC ( #615718=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Timestamp problem
in thread Timestamp problem

It gets inserted as "000..." because you pass an invalid date/timsetamp value - don't use localtime in scalar context, but in list-context and use the resulting array to assemble a string as described in the MySQL documentation.
But as I tried to say: You don't need to format it, as you should be able to use FROM_UNIXTIME to convert a unix-timestamp (seconds since epoch) into something mysql is able to treat as an sql-timestamp.

What I don't understand is, what you want to achieve, as you don't get a date by subtracting old_date from now(), that could be used as a timestamp in a meaningful way, but an intervall in seconds. You shouldn't store these as timestamp-values but as integers - as they aren't timestamps (referring to a point in time).

In short: I guess you try to solve the wrong problem, or you didn't state the real problem - or maybe both..., nevertheless reading the docs I pointed you to should enable you to format the values you have to solve your stated problem in the way you want - namely inserting the difference as sql-timestamp.

regards,
tomte


An intellectual is someone whose mind watches itself.
-- Albert Camus


Comment on Re^3: Timestamp problem
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://615718]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2014-04-20 12:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls