DATETIME (yyyy-mm-dd hh:mm:ss) Difference in minutes
I need function that returns difference between two datetimes in seconds.
|
Re: DATETIME (yyyy-mm-dd hh:mm:ss) Difference in minutes
I recommend storing time in unix timestamp format, much easier to manage and do calculations with.
|
Re: DATETIME (yyyy-mm-dd hh:mm:ss) Difference in minutes
Thank you, I didn't know about that before.
EDIT: can you just give me an example of the best way to get difference ? |
Re: DATETIME (yyyy-mm-dd hh:mm:ss) Difference in minutes
new diff = get_systime() - timestamp
|
Re: DATETIME (yyyy-mm-dd hh:mm:ss) Difference in minutes
Yes, and you can easily convert a timestamp to any time value you want, down to the second.
|
Re: DATETIME (yyyy-mm-dd hh:mm:ss) Difference in minutes
So I have to use TimeToUnix to convert DATETIME from database to unix format ?
|
Re: DATETIME (yyyy-mm-dd hh:mm:ss) Difference in minutes
How are you saving the date in the database as Unix timestamp value or as string date value.?
If you are saving it as a date you need to convert it to unix timestamp using bugsy include file for converting the date to unix its for easier purpose https://forums.alliedmods.net/showth...=91915?t=91915 |
Re: DATETIME (yyyy-mm-dd hh:mm:ss) Difference in minutes
Code:
warning 213: tag mismatchPHP Code:
|
Re: DATETIME (yyyy-mm-dd hh:mm:ss) Difference in minutes
You cannot use the string version of time with this method.
PHP Code:
|
Re: DATETIME (yyyy-mm-dd hh:mm:ss) Difference in minutes
Quote:
PHP Code:
It will print the time difference in seconds, if you want to print full information (days/months/etc) then take a look at Bugsy's code right above me. |
| All times are GMT -4. The time now is 07:36. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.