SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 27/11/2009, 10:29 PM   #1
Outbreak
Huge Clucker
 
Join Date: Dec 2008
Posts: 303
Reputation: 3
Default Is it possible to convert gettime() into Date and Time?

Hi, just wondering, I'd like to store the time in seconds for two sepperate uses.

I would like to store it using gettime(); so then it would give me the long number in seconds.

I'm wondering if there is a way to convert that into dd/mm/yyyy 00:00

I know already about getdate(year, month,day); But i dont wan't to use that way, i will if i have to but i would prefer to convert seconds into day, month, year, and time.

If it is possible. Would be more or less efficient to store it sepperatly using gettime(); and then getdate(year,month,day);
Outbreak is offline  
Old 27/11/2009, 10:33 PM   #2
RyDeR`
High-roller
 
RyDeR`'s Avatar
 
Join Date: Feb 2009
Location: Belgium
Posts: 2,929
Reputation: 700
Default Re: Is it possible to convert gettime() into Date and Time?

getdate
__________________

Sup?
RyDeR` is offline  
Old 27/11/2009, 10:37 PM   #3
miokie
High-roller
 
miokie's Avatar
 
Join Date: Jan 2007
Location: Bedfordshire, England
Posts: 1,148
Reputation: 13
Default Re: Is it possible to convert gettime() into Date and Time?

As far as I know you can do:

pawn Code:
new Hours,Minutes,Seconds;

pawn Code:
gettime(Hours,Minutes,Seconds);

Then Use the Hours, Minutes And Seconds to do what ever you want like formatting it into a SendClientMessage:

pawn Code:
format(String,sizeof(String),"The Time Is: %d Hours, %d Minutes and %d Seconds!",Hours,Minutes,Seconds);

Is that what you mean or have i completly lost the point?

Ok I re-readed Your post, Ignore all that...
__________________
miokie is offline  
Old 27/11/2009, 10:40 PM   #4
Outbreak
Huge Clucker
 
Join Date: Dec 2008
Posts: 303
Reputation: 3
Default Re: Is it possible to convert gettime() into Date and Time?

i need to store it as a long number that you get when you use gettime();

Then use that long number for one thing, and also use the same long number for converting into dd/mm/yyyy 00:00 so day month year and time


If its to long a process then i'll simply use gettime() for one and convert it to 00:00 for the one where i will need getdate(year,month,day);

Outbreak is offline  
Old 27/11/2009, 10:51 PM   #5
miokie
High-roller
 
miokie's Avatar
 
Join Date: Jan 2007
Location: Bedfordshire, England
Posts: 1,148
Reputation: 13
Default Re: Is it possible to convert gettime() into Date and Time?

I think you would basically need to find out how many seconds there are in 2009 Years 11 Months, 27 Days Etc...

I'm not sure if this is possible at all thinking about it.

I thought of something but that epicly failed when I realised it would only get the seconds from 00:00...

Well yeah, I'm not sure if its possible...

Edit:
Btw, Theres been around roughly 63,387,619,200 Seconds not including todays time since 00:00 and Not including leap years.
Ahh, I'm so Nerdy with my free time

If thats any help to you... Loll :P
__________________
miokie is offline  
Old 27/11/2009, 10:59 PM   #6
Outbreak
Huge Clucker
 
Join Date: Dec 2008
Posts: 303
Reputation: 3
Default Re: Is it possible to convert gettime() into Date and Time?

Alright no worries..

Thanks for all the replies.

I'll use gettime(); for the seconds and getdate(year,month,day);

Its no real extra effort, just creating one extra field. I was just curious to whether it could be done.

Thanks again
Outbreak is offline  
Old 27/11/2009, 10:59 PM   #7
yezizhu
Gangsta
 
yezizhu's Avatar
 
Join Date: Nov 2007
Location: Shenzhen,China
Posts: 641
Reputation: 2
Default Re: Is it possible to convert gettime() into Date and Time?

Code:
getdateEx(bool:t=true){
  new
    y,m,d,
    r[t?9:11];
  getdate(y,m,d);
  t?format(r,9,"%d",d+100*m+10000*y):format(r,11,"%04d/%02d/%02d",y,m,d);
  return r;
}
or
Code:
getdateEx(){
  new
    y,m,d;
  getdate(y,m,d);
  return d+100*m+100000*y;
}
Choose u like.

Edit1: 'd re-read ur post, I just found I was doing wrong thing :{
yezizhu is offline  
Old 27/11/2009, 11:06 PM   #8
yezizhu
Gangsta
 
yezizhu's Avatar
 
Join Date: Nov 2007
Location: Shenzhen,China
Posts: 641
Reputation: 2
Default Re: Is it possible to convert gettime() into Date and Time?

Do you need convert seconds to y/m/d?
If yes, as far as I know, there's a function you need in topic useful function.
yezizhu is offline  
Old 27/11/2009, 11:32 PM   #9
Outbreak
Huge Clucker
 
Join Date: Dec 2008
Posts: 303
Reputation: 3
Default Re: Is it possible to convert gettime() into Date and Time?

double poster /ban lol

Thanks, i'll check it out.
Outbreak is offline  
 

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] [FS] Real Time and Date b00m Filterscripts 44 14/07/2013 03:30 AM
[FilterScript] [FS] Time & Date 4#Future Filterscripts 69 05/08/2012 08:30 PM
Date & Time Mike Garber Help Archive 6 24/11/2009 06:10 PM
BAN, gives = ban id:, time, admin, date, etc.. XeoN_13 Help Archive 0 15/03/2009 05:06 AM


All times are GMT. The time now is 07:59 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.