I have implemented my own script for auctions. But my problem is how to handle time.
Right now all auctions are based on UTC time, so whatever user's timezone is when he/she comes to site auction will start and end at the same time(UTC). I used date_default_timezone_set('UTC') to set default timezone throughout whole site.
But I guess that might be little bit confusing for users. Did anyone have similar problem and what could be the best solution for it.
I created a family website (family around the world).
All dates were stored with timestamp (which is UTC-timezone independent).
When a member created an account, he/she had to enter the country he/she was living it (as the PHP timezone guess is not reliable).
From that, I stored the name of the timezone of his /her country (https://php.net/manual/en/timezones.php).
When the member logs in, I PHP-set the timezone to his/her country to display dates with his/her timezone.
Related
My website is relaying heavily on FB. There is only FB login and all comunication with members happens through facebook. Users are notified using FB api about activities in site that they would care about. Users can choose between three options:
Never notify
Notify once a day(for MVP version I am good with hardcoded time, lets say, 9 in moorning, but probably aiming for possability for user to choose when they want to be notified about everything that has happened in last 24h)
Notify on-the-go
First and third are easy, my concerns lies on second option. Basically its similar to newsletter. Here is my idea of this process so far:
When ever some action that is of concern for user happens, notification about that is saved in database
if user logs into site before scheduled time notification is marked as read
if user does not log into site before scheduled time unread notifications will be included in cron job
every hour cron job is run. It matches the users time zone with current time so that only only users that are awake will recive notification. Users will get basic "there are new things in site" notification.
Problem: From FB I can get only offset as integer, not actual timezone. I have spent some time on reading about timezone and different formats and it strikes me that FB call to get timezone results in offset.
Sending newletter(notification in my case) to different time zones is complex but there are a lot of good resource available. However it seems that best way to do that is save user time zone as TZ database format America/New_York. So my question is dual
Is it possible to somehow get user time zone in TZ from facebook?
If not, what would be my best actions? Whats important is that I dont care if user dont get notification at exact time. With that I mean that I dont care about summer time difference. it would be ok if user could chose between moorning, afternoon and evening(and if for example he chooses moorning, then he would get notification 9:00 +/- 1 hour). I am open to ideas, at given point my main consern is to get MVP running.
$ch = curl_init("https://graph.facebook.com/v2.6/" . $user_id . "?fields=timezone&access_token=" . $fb_access_token);
curl_setopt_array($ch, array(
CURLOPT_RETURNTRANSFER => 1
));
$result = curl_exec($ch);
You can get the user timezone from the open graph api.
For converting the offset to an actual timezone see the answer here: Convert UTC offset to timezone or date
I want to get the timezone of current surfer or user which is using the website. Like (GMT-6). Actually I have to put some check on users of Tulsa Oklahoma so some user in that state is using the website will come under that check.
I think if i become able to get GMT difference like -6 then I can put check. I want to do this thing preferably in php but can consider javascript also.
Thanks in advance.
Show reminder pop-up for one customer based on the follow-up time reached for customers.
Scenario
I have 10 customers, i have set follow-up date and time for those customers between 10 am to 5 pm on today. If any customer's follow up date and time is reached that time will show pop-up with their details.
Performance Issue
Normally, This event will trigger, when the date and time is reached that time only trigger, So every second we should check the server time with corresponding tables. So If we check this kind of matching data in DB, definitely we should face performance/Lock issue.
How can be this done with efficiency using php, jquery or any other tools??
The same logic you can apply with a small modification.
Take the server time from the server and at the same time take all user ids and their follow-up date and time who all having the follow-up date and time in the same day (or all if there are no more no of users) and store it in client side (Cookie or local storage).
So every time you can check the date time(Take server time stored in client side cookie as reference) in the client side itself and if there is any match occurs only you7 need to make a call to the server side in order to take the corresponding details.
i need some help to plan an effective algorithm to check who is online to my web site, with PHP and AJAX.
(i dont need you to write any sourse to me!!)
the biggest problem is how to know when the member get off.
in the end, it will be a list of online members that alwayes update, like what facebook have.
You can use a timestamp, with PHP you can do strtotime("now");
You add that timestamp to the user's table in MySQL, or their session info. Then, you update that timestamp whenever the user changes pages or accesses the site. To determine if the user is offline, you can remove the timestamp when the user logs off, and if the user just exits without logging off, you would just compare the timestamp to the current time.
For example, you could look to see if 15 minutes has passed by checking the timestamp variable like this:
if($timestamp <= strtotime("-15 minutes")) echo "User is offline";
My file tracking system deals with application submission. Date of the application is used to track total days taken to process each application. However, event though current date is shown, user able to change it to past date in my system. The system use mvc framework. What should i do to make the date inaccessible by user? Something like static.
Just store the date against the application id in the database when the application is first submitted and then ignore any mention of the date in the submitted form data.