Raised This Month: $51 Target: $400
 12% 

Converting a specific date to epoch


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bladell
Senior Member
Join Date: Jun 2012
Old 07-19-2014 , 13:14   Converting a specific date to epoch
Reply With Quote #1

I want to make a plugin wich execute a certain command at a specific time. There are some cvar like:
Code:
	p_Year = register_cvar("sh_resetyear", "2014")
	p_Month = register_cvar("sh_resetmonth, "1")
	p_Day = register_cvar("sh_resetday", "1")
	p_Hour = register_cvar("sh_resethour", "1")
	p_Minute = register_cvar("sh_resetminute", "1")
	p_Second = register_cvar("sh_resetsecond", "1")
So, in 2014, first month of the year, first day of the month, first hour of the day, first minute of the hour and first second of the minute a command will be executed.
I need to transform a date into epoch time so I could use get_systime() and obatin the difference(in seconds) between today and a specific date. After I get the result of this difference I can easily find out how many days, hours, minutes and seconds are until the execution of the command, so I can show it on a hud message.
Now you know what my plugin should do. I think that this method is the best, if you know another wich is better please share it with me or help me to transform a specific date into epoch.
Bladell is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 07-19-2014 , 13:39   Re: Converting a specific date to epoch
Reply With Quote #2

Well, as far as I know, you have to convert each value to seconds (because that's the value of get_systime). So simply increase the values by 60, 3600, 86400, etc. I tihnk you got my idea. Take a look here, too, https://forums.alliedmods.net/showthread.php?t=23912
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Bladell
Senior Member
Join Date: Jun 2012
Old 07-21-2014 , 03:13   Re: Converting a specific date to epoch
Reply With Quote #3

Right... I have to convert each value to seconds. Try to convert a date and you'll find out that is not as simple as you think since there are years with 365 days, 366 days etc...
Bladell is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 07-21-2014 , 03:38   Re: Converting a specific date to epoch
Reply With Quote #4

Rather than trying to figure out how to convert it, try explaining what it is that you are doing. There may be an easier way
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 07-21-2014 , 05:17   Re: Converting a specific date to epoch
Reply With Quote #5

Also, there is a cronjob plugin for AMXX.
__________________
Currently busy working on a very large scale anime database project.
Backstabnoob is offline
Bladell
Senior Member
Join Date: Jun 2012
Old 07-21-2014 , 07:17   Re: Converting a specific date to epoch
Reply With Quote #6

I am trying to make a plugin wich execute a command at a specific date, hour and minute. This plugin should also show a cooldown in last 3 days.(e.g. 2 days, 8 hours, 1 minute, 32 seconds)
Bladell is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 07-21-2014 , 08:13   Re: Converting a specific date to epoch
Reply With Quote #7

I like the fact you completely ignored my post, but I'll be nice and post you a link anyway:
https://forums.alliedmods.net/showth...=69068?t=69068
__________________
Currently busy working on a very large scale anime database project.
Backstabnoob is offline
Bladell
Senior Member
Join Date: Jun 2012
Old 07-21-2014 , 09:33   Re: Converting a specific date to epoch
Reply With Quote #8

I ignored your post because it doesn't help me. I already knew about this plugin... isn't good for me because have many useless features for me. Also, I can't add a hud countdown message.
Bladell is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 07-21-2014 , 10:47   Re: Converting a specific date to epoch
Reply With Quote #9

Then good luck recreating something that already exists.
__________________
Currently busy working on a very large scale anime database project.
Backstabnoob is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 07-21-2014 , 22:26   Re: Converting a specific date to epoch
Reply With Quote #10

Our friend Bugsy made a useful include time ago: https://forums.alliedmods.net/showthread.php?t=91915 take a look and use TimeToUnix.
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
Reply



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 19:17.


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