Raised This Month: $ Target: $400
 0% 

Time difference


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 06-12-2010 , 09:58   Time difference
Reply With Quote #1

Hey. I want to know, if I have a time like:
2010-05-27 16:115

How can I check, if three minutes passed from that time? Like

time is 2010-05-27 16:115
new newtime[x]
get_time(newtime, xxx)

if((newtime - time) > 3)
passed


but I need an exact example, cause I do not know.
Thanks in advance.
Backstabnoob is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-12-2010 , 10:07   Re: Time difference
Reply With Quote #2

Are you able to use any other method for your storing your times? It can be done using a string time format like that but it will take more work. It would be easier if you stored the times in unix-time format (timestamp). You can easily determine exact difference (down to seconds) in 2 times with this.

http://forums.alliedmods.net/showthread.php?t=91915
__________________
Bugsy is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 06-12-2010 , 10:30   Re: Time difference
Reply With Quote #3

Yeah, I can do it with timestamp, just couldn't find that.

Can you show me an example of how to get the difference?
Backstabnoob is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-12-2010 , 10:37   Re: Time difference
Reply With Quote #4

Quote:
Originally Posted by Backstabnoob View Post
Yeah, I can do it with timestamp, just couldn't find that.

Can you show me an example of how to get the difference?
All you have to do is subtract one time from the other then divide by X to determine the difference in years, months, days, hours, minutes, seconds or w\e.

Use get_systime() in your plugin to get the current unix time.

Current time = 1276338840
5 hours from now = 1276356840

1276356840 - 1276338840 = 18000

MinuteSeconds = 60
HourSeconds = 3600
DaySeconds = 86400

18000 / 3600 = 5
__________________
Bugsy is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:48.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode