Is it possible to convert gettime() into Date and Time?
#1

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);
Reply
#2

getdate
Reply
#3

As far as I know you can do:

pawn Код:
new Hours,Minutes,Seconds;
pawn Код:
gettime(Hours,Minutes,Seconds);
Then Use the Hours, Minutes And Seconds to do what ever you want like formatting it into a SendClientMessage:

pawn Код:
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...
Reply
#4

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);

Reply
#5

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
Reply
#6

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
Reply
#7

Код:
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
Код:
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 :{
Reply
#8

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.
Reply
#9

double poster /ban lol

Thanks, i'll check it out.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)