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

How to create timestamp ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Küspert
SourceMod Donor
Join Date: Aug 2006
Location: Germany
Old 01-30-2009 , 10:30   How to create timestamp ?
Reply With Quote #1

Hi,

I have the following problem:

On of my plugins has stored a time in the format HH:MM (24 hour style) in a keyvalues file.

Now I want to comparer the current timestamp and and the one generated out of the time in the database, e.g. 150

How can I create the timestamp for the day and this hour out of this value ?

Cause with the difference I want to create a timer.

Hope you understand
Küspert is offline
Send a message via ICQ to Küspert
Küspert
SourceMod Donor
Join Date: Aug 2006
Location: Germany
Old 01-31-2009 , 06:08   Re: How to create timestamp ?
Reply With Quote #2

Hmm the only idea I had is, to compare every minutes via a timer the time.

But I don't think this is the smooth way

But if there's no other way
Küspert is offline
Send a message via ICQ to Küspert
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 01-31-2009 , 12:38   Re: How to create timestamp ?
Reply With Quote #3

A timestamp isn't just hours and minutes, it also contains the year and the date. To be more exact it's the seconds since 1970. I think there is no way
with sourcemod to calculate a timestamp based on a datetime.
So you have to compare the hours and minutes as numbers and calculate the time difference yourself.

Time difference = (currentHours*3600+currentMinutes*60)-(keyValueHours*3600+keyValueMinutes*60)

KeyValuesTimestamp = GetTime() - Time difference

I'm not sure if that's what you want, but I think it might give you a hint how to start
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0

Last edited by berni; 01-31-2009 at 12:40.
berni is offline
Küspert
SourceMod Donor
Join Date: Aug 2006
Location: Germany
Old 02-04-2009 , 12:22   Re: How to create timestamp ?
Reply With Quote #4

Ty for the hint.

That was what I needed
Küspert is offline
Send a message via ICQ to Küspert
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 21:03.


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