hlmod.hu
https://hlmod.hu/

Intből dátum
https://hlmod.hu/viewtopic.php?f=9&t=29039
Oldal: 1 / 1

Szerző:  Vieni [ 2018.06.05. 12:29 ]
Hozzászólás témája:  Intből dátum

Sziasztok!
Az érdekelne, hogy hogyan tudnék dátumot létrehozni egy számból? :?
Kerestem rá parancsot, de nem találtam. Tudom meglehetne oldani, csak gondolom van rá valami parancs is. :D

Segítségeteket előre is köszönöm! ;)

Szerző:  ultraibolya [ 2018.06.05. 13:16 ]
Hozzászólás témája:  Re: Intből dátum

Egy példát tudnál írni? Milyen számra gondolsz?
Nekem ez ugrott be:
20170204
Ilyenre gondolsz?

Szerző:  Vieni [ 2018.06.05. 13:18 ]
Hozzászólás témája:  Re: Intből dátum

ultraibolya írta:
Egy példát tudnál írni? Milyen számra gondolsz?
Nekem ez ugrott be:
20170204
Ilyenre gondolsz?


Ilyenekből kéne :D
getsystime() + 86400*19

Szerző:  JohanCorn [ 2018.06.05. 13:35 ]
Hozzászólás témája:  Re: Intből dátum

Ha timestampet akarsz dátummá alakítani, akkor használhatod a format_time funkciót.

Szerző:  Dooz [ 2018.06.05. 13:36 ]
Hozzászólás témája:  Re: Intből dátum

Próbáld meg ezt (Egy pluginból másoltam ki):

  1. public Datum(id){
  2.         new Date[64], len = 0;
  3.         static _hours[5], _minutes[5], _seconds[5], _month[5], _day[5], _year[7];
  4.         format_time(_hours, sizeof(_hours) - 1, "%H");
  5.         format_time(_minutes, sizeof(_minutes) - 1, "%M");
  6.         format_time(_seconds, sizeof(_seconds) - 1, "%S");
  7.         format_time(_month, sizeof(_month) - 1, "%m");
  8.         format_time(_day, sizeof(_day) - 1, "%d");
  9.         format_time(_year, sizeof(_year) - 1, "%Y");
  10.  
  11.         new hours = str_to_num(_hours);
  12.         new minutes = str_to_num(_minutes);
  13.         new seconds = str_to_num(_seconds);
  14.         new month = str_to_num(_month);
  15.         new day = str_to_num(_day);
  16.         new year = str_to_num(_year);
  17.  
  18.         day += NapokSzama; //Itt adod majd hozzá a napok számát
  19.  
  20.         new max_days = GetDaysInMonth(month, year);
  21.        
  22.         while( day > max_days )
  23.         {
  24.             day -= max_days;
  25.             month++;
  26.         }
  27.  
  28.         while( month > 12 )
  29.         {
  30.             month -= 12;
  31.             year++;
  32.         }
  33.  
  34.         formatex(Date[len], charsmax(Date)-len, "%i/%i/%i - %02i:%02i:%02i", year, month, day, hours, minutes, seconds);
  35.         client_print(id, print_chat, "A datum: %s",Date);
  36. }
  37.        
  38.  
  39. GetDaysInMonth(month, year=0)
  40. {
  41.     switch( month )
  42.     {
  43.     case 1:         return 31; // january
  44.     case 2:         return ((year % 4) == 0) ? 29 : 28; // february
  45.     case 3:         return 31; // march
  46.     case 4:         return 30; // april
  47.     case 5:         return 31; // may
  48.     case 6:         return 30; // june
  49.     case 7:         return 31; // july
  50.     case 8:         return 31; // august
  51.     case 9:         return 30; // september
  52.     case 10:        return 31; // october
  53.     case 11:        return 30; // november
  54.     case 12:        return 31; // december
  55.     }
  56.  
  57. return 30;
  58. }

Szerző:  Vieni [ 2018.06.05. 13:42 ]
Hozzászólás témája:  Re: Intből dátum

Dooz írta:
Próbáld meg ezt (Egy pluginból másoltam ki):

  1. public Datum(id){
  2.         new Date[64];
  3.         static _hours[5], _minutes[5], _seconds[5], _month[5], _day[5], _year[7];
  4.         format_time(_hours, sizeof(_hours) - 1, "%H");
  5.         format_time(_minutes, sizeof(_minutes) - 1, "%M");
  6.         format_time(_seconds, sizeof(_seconds) - 1, "%S");
  7.         format_time(_month, sizeof(_month) - 1, "%m");
  8.         format_time(_day, sizeof(_day) - 1, "%d");
  9.         format_time(_year, sizeof(_year) - 1, "%Y");
  10.  
  11.         new hours = str_to_num(_hours);
  12.         new minutes = str_to_num(_minutes);
  13.         new seconds = str_to_num(_seconds);
  14.         new month = str_to_num(_month);
  15.         new day = str_to_num(_day);
  16.         new year = str_to_num(_year);
  17.  
  18.         day += NapokSzama; //Itt adod majd hozzá a napok számát
  19.  
  20.         new max_days = GetDaysInMonth(month, year);
  21.        
  22.         while( day > max_days )
  23.         {
  24.             day -= max_days;
  25.             month++;
  26.         }
  27.  
  28.         while( month > 12 )
  29.         {
  30.             month -= 12;
  31.             year++;
  32.         }
  33.  
  34.         formatex(Date[len], charsmax(Date)-len, "%i/%i/%i - %02i:%02i:%02i", year, month, day, hours, minutes, seconds);
  35.         client_print(id, print_chat, "A datum: %s",Date);
  36. }
  37.        
  38.  
  39. GetDaysInMonth(month, year=0)
  40. {
  41.     switch( month )
  42.     {
  43.     case 1:         return 31; // january
  44.     case 2:         return ((year % 4) == 0) ? 29 : 28; // february
  45.     case 3:         return 31; // march
  46.     case 4:         return 30; // april
  47.     case 5:         return 31; // may
  48.     case 6:         return 30; // june
  49.     case 7:         return 31; // july
  50.     case 8:         return 31; // august
  51.     case 9:         return 30; // september
  52.     case 10:        return 31; // october
  53.     case 11:        return 30; // november
  54.     case 12:        return 31; // december
  55.     }
  56.  
  57. return 30;
  58. }

JohanCorn írta:
Ha timestampet akarsz dátummá alakítani, akkor használhatod a format_time funkciót.

Köszönöm mindkettőtöknek! :D

Oldal: 1 / 1 Minden időpont UTC+02:00 időzóna szerinti
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/