Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Comparing different timestamp formats

by tangent (Parson)
on Oct 24, 2018 at 21:59 UTC ( [id://1224624]=note: print w/replies, xml ) Need Help??


in reply to Comparing different timestamp formats

As haukex points out, you can use the database functions to calculate the difference. You can select the interval between now and the timestamp you have like this:
SELECT TIMESTAMPDIFF( MINUTE, STR_TO_DATE('Tue Oct 23, 2018 - 19:57:12','%a %b %d, %Y - %T'), NOW() );
That will return the difference in minutes - you can use SECOND as well. In your SQL query you might have something like this:
SELECT column_name, TIMESTAMPDIFF( SECOND, STR_TO_DATE(column_name,'%a %b %d, %Y - %T'), NOW() ) FROM table;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-25 10:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found