| 
	
 | 
 Posted by Rik on 10/23/06 17:04 
Aggelos wrote: 
> I suppose that has been discussed. I search on google but couldn't 
> find a short answer. 
> I have a datetime field: 2006-10-10 12:00:00 
> And I want to get that in seconds. 
> Should I break the date and time and calculate it in two steps ? 
> or is there a quick way to do it in one step ? 
> I am trying to set the rate of a process execution between two 
> datetimes and I am going to need everydate in seconds. 
 
When you say 'field', do you mean a database field? Most databases offer 
their own logic for this, for instance in MySQL: 
 
SELECT UNIX_TIMESTAMP(NOW()) 
 
or 
SELECT UNIX_TIMESTAMP(`field`) FROM `table` 
 
Other databases often have similar conststructs. 
In PHP, you could use strtotime(), but if the data comes from a database I 
strongly recommend to let the database handle it. 
--  
Grtz, 
 
Rik Wasmus
 
  
Navigation:
[Reply to this message] 
 |