You are here: Re: Convert datetime to unix timestamp « PHP Programming Language « IT news, forums, messages
Re: Convert datetime to unix timestamp

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация