Posts: 1,753
Threads: 277
Joined: Sep 2010
Reputation:
0
How do I get the day/month that we're currently in? (In real life)
Posts: 10,066
Threads: 38
Joined: Sep 2007
Reputation:
0
getdate(). You can't find out the day of the week (Monday, Tuesday, etc) though. At least you can't without some sophisticated coding. A mysql server can calculate the day of the week, as well as the CTime library (read that somewhere).
Posts: 1,753
Threads: 277
Joined: Sep 2010
Reputation:
0
I use MySQL, but I really don't understand how to get the day and month.
I just read up about the GetDate function, I could possible try make a stock for the month thing, but the day thing, maybe difficult.
Although, I could start on today, EG:
if(day == 30) format(string, sizeof(string), "Wednesday");
Could that work? Thanks!
Posts: 6,129
Threads: 36
Joined: Jan 2009
Fortunately, I found this after searching:
pawn Код:
// Credit to yom
stock GetWeekDay(day=0, month=0, year=0) {
if(!day)
getdate(year, month, day);
new
szWeekDay[10],
j,
e;
if(month <= 2) {
month += 12;
--year;
}
j = year % 100;
e = year / 100;
switch((day + (month+1)*26/10 + j + j/4 + e/4 - 2*e) % 7) {
case 0: szWeekDay = "Saturday";
case 1: szWeekDay = " Sunday";
case 2: szWeekDay = " Monday";
case 3: szWeekDay = " Tuesday";
case 4: szWeekDay = "Wednesday";
case 5: szWeekDay = "Thursday";
case 6: szWeekDay = " Friday";
}
return szWeekDay;
}
It seemed to work when I
tested (though the test script will return the day for 2 days ago as I subtracted 2 from the day count after getdate()) it.
Posts: 1,753
Threads: 277
Joined: Sep 2010
Reputation:
0
Thank you Calgon!
Are you on MSN matey?