Raised This Month: $ Target: $400
 0% 

Adding days, hours, seconds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
OnePL
BANNED
Join Date: May 2012
Location: GB
Old 06-25-2012 , 17:37   Adding days, hours, seconds
Reply With Quote #1

Hello

Can somebody add to showed the days, hours, minutes and eventually seconds?
And to save the database in the same form (days, hours, minutes and eventually seconds)

Spoiler

Last edited by OnePL; 06-25-2012 at 17:37.
OnePL is offline
Send a message via ICQ to OnePL Send a message via AIM to OnePL Send a message via Yahoo to OnePL Send a message via Skype™ to OnePL
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-25-2012 , 18:24   Re: Adding days, hours, seconds
Reply With Quote #2

seconds = get_systime()
Minutes = seconds / 60
hours = Minutes / 60
days = hours / 24

if that doesn't help you. go to request.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-25-2012 , 19:15   Re: Adding days, hours, seconds
Reply With Quote #3

Quote:
Originally Posted by Liverwiz View Post
seconds = get_systime()
Minutes = seconds / 60
hours = Minutes / 60
days = hours / 24

if that doesn't help you. go to request.
You will want to rethink that . . .

I do it this way:

PHP Code:
new days seconds 86400
new hours seconds 86400 3600
new minutes seconds 3600 60
new seconds seconds 60 
__________________
fysiks is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-25-2012 , 19:40   Re: Adding days, hours, seconds
Reply With Quote #4

Quote:
Originally Posted by fysiks View Post
PHP Code:
new days seconds 86400
new hours seconds 86400 3600
new minutes seconds 3600 60
new seconds seconds 60 
I'd rethink that too.....
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
OnePL
BANNED
Join Date: May 2012
Location: GB
Old 06-25-2012 , 20:34   Re: Adding days, hours, seconds
Reply With Quote #5

I know, but I want to save in form D: H: M: S in SQL
Add someone?
OnePL is offline
Send a message via ICQ to OnePL Send a message via AIM to OnePL Send a message via Yahoo to OnePL Send a message via Skype™ to OnePL
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-25-2012 , 21:22   Re: Adding days, hours, seconds
Reply With Quote #6

Quote:
Originally Posted by Liverwiz View Post
if that doesn't help you. go to request.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-25-2012 , 23:42   Re: Adding days, hours, seconds
Reply With Quote #7

Quote:
Originally Posted by Liverwiz View Post
I'd rethink that too.....
LOL. Oh really? Why do you say that? Do I have to prove you wrong? I will if you want.

EDIT: I won't wait for your response:

PHP Code:
#include <amxmodx>

public plugin_init()
{
    
set_task(5.0"runProof")
}

public 
runProof()
{
    new 
iTestTest 4687987
    
    
// Liverwiz's Method
    
new seconds iTestTest
    
new minutes seconds 60
    
new hours minutes 60
    
new days hours 24

    server_print
("^nLiverwiz's Method:")
    
server_print("%d Days %d Hours %d Minutes and %d Seconds"dayshoursminutesseconds)

    
// Fysiks' Method
    
new iDays iTestTest 86400
    
new iHours iTestTest 86400 3600
    
new iMinutes iTestTest 3600 60
    
new iSeconds iTestTest 60

    server_print
("^nFysiks' Method:")
    
server_print("%d Days %d Hours %d Minutes and %d Seconds"iDaysiHoursiMinutesiSeconds)

Yields:

Code:
Liverwiz's Method:
54 Days 1302 Hours 78133 Minutes and 4687987 Seconds

Fysiks' Method:
54 Days 6 Hours 13 Minutes and 7 Seconds
I'll let you decide which is correct.
__________________

Last edited by fysiks; 06-26-2012 at 00:02.
fysiks is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-26-2012 , 00:04   Re: Adding days, hours, seconds
Reply With Quote #8

Quote:
Originally Posted by fysiks View Post
You will want to rethink that . . .

I do it this way:

PHP Code:
new days seconds 86400
new hours seconds 86400 3600
new minutes seconds 3600 60
new seconds seconds 60 
and


Quote:
Originally Posted by fysiks View Post
LOL. Oh really? Why do you say that? Do I have to prove you wrong? I will if you want.

EDIT: I won't wait for your response:

PHP Code:
    // Fysiks' Method
    
new iDays iTestTest 86400
    
new iHours iTestTest 86400 3600
    
new iMinutes iTestTest 3600 60
    
new iSeconds iTestTest 60 
.

are different.

You really go through a lot of effort in proving someone wrong, rather than actually helping anyone. When did i sleep with your wife?
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 06-26-2012 at 00:05.
Liverwiz is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-26-2012 , 00:07   Re: Adding days, hours, seconds
Reply With Quote #9

Quote:
Originally Posted by Liverwiz View Post
are different.

You really go through a lot of effort in proving someone wrong, rather than actually helping anyone. When did i sleep with your wife?
They are the same. I just added an extra "new" because I got it from an old post.

I don't have a wife so you can sleep with her all you want.
__________________
fysiks is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-26-2012 , 00:08   Re: Adding days, hours, seconds
Reply With Quote #10

go compile the first one and tell me if you're still right.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz 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 06:16.


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