U
Ukaygee
Guest
Hey!
So I'm trying to make a programme that, when given a date by a user, in the format DD/MM/YYYY, the programme checks to see if that given date is 2 weeks ago or more.
To do this, I have got the current second of the year, which at the date of writing this is ~14,060,000, and I am trying to take 1209600 away from the current date, to find out what the second of the year was exactly two weeks ago, then comparing that with the inputted value, and then if the inputted value is less than the current second take away 1209600, then it is more than two weeks ago.
The problem I have is that I don't know how to get the exact second of the year of a specified date.
I tried this:
**EDIT**
I realise this may be a complicated explanation, essentially, I just want to know how to convert any date into the second of the year that is.
Or, if that's not possible, I just want to know how to compare a given date to the current date and see if its more than two weeks ago.
* * * *
Anyone have any ideas?
So I'm trying to make a programme that, when given a date by a user, in the format DD/MM/YYYY, the programme checks to see if that given date is 2 weeks ago or more.
To do this, I have got the current second of the year, which at the date of writing this is ~14,060,000, and I am trying to take 1209600 away from the current date, to find out what the second of the year was exactly two weeks ago, then comparing that with the inputted value, and then if the inputted value is less than the current second take away 1209600, then it is more than two weeks ago.
The problem I have is that I don't know how to get the exact second of the year of a specified date.
I tried this:
Code:
givendate = date_create_datetime(2016,5,29,0,0,0);
Code:
currentsecond = date-get_second_of_year(date_current_datetime());
datesecond = date_get_second_of_year(givendate);
if (datesecond < currentsecond - 1209600)
{
show_debug_message("It was longer than two weeks ago!");
}
I realise this may be a complicated explanation, essentially, I just want to know how to convert any date into the second of the year that is.
Or, if that's not possible, I just want to know how to compare a given date to the current date and see if its more than two weeks ago.
* * * *
Anyone have any ideas?
Last edited: