Hi,
In my download manager script I want to increment the download count when ever user downloads the script and also i want to check whether the user download the script more than once within that day, For this i want to compare the current timestamp with the timestamp period for that day. Please help me how to do this comparison.
Thanks in advance
Geetha
timestamp comparison
Moderator: General Moderators
-
geethalakshmi
- Forum Commoner
- Posts: 31
- Joined: Thu Apr 24, 2008 10:38 pm
timestamp comparison
Last edited by onion2k on Wed Aug 27, 2008 6:49 am, edited 1 time in total.
Reason: Unnecessary link removed. Don't add it again or you'll be banned for spamming.
Reason: Unnecessary link removed. Don't add it again or you'll be banned for spamming.
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
Re: timestamp comparison
Incrementing a download count is trivial, so I won't go into that.
Your second question, do you mean within the last 24 hours or actually on the same day (date)? You could do this in SQL or PHP quite easily, possibly using INTERVAL for the former and mktime() for the latter.
Your second question, do you mean within the last 24 hours or actually on the same day (date)? You could do this in SQL or PHP quite easily, possibly using INTERVAL for the former and mktime() for the latter.
Re: timestamp comparison
Code: Select all
$dateParts = date_parse('2008-08-27');
$timestamp = mktime($dateParts ['hour'], $dateParts ['minute'], $dateParts ['second'], $dateParts ['month'], $dateParts ['day'], $dateParts ['year']);
if($timestamp > mktime()) {
print 'The date is in the future';
elseif($timestamp < mktime()) {
print 'The date is in the past';
}