Two questions:
I'm once again creating a social network for a niche domain name that I own. One feature that I want to offer is an event calendar. Even if I didn't have an event calendar, when people post messages, comments, etc. the time is recorded and that way a user can see when something was posted.
The way I've always done it is to just record the date/time and later echo it back, although as you can imagine the time will almost always be incorrect since it is based off of the server's timezone.
What is the best way to show accurate times for people?
I've been told to use a unix timestamp and to convert the numeric data into a date, which makes working with dates much easier since it is an integer. However this is just going to give me my local server time or whatever.
Someone mentioned something about utc time or something like that, but then I will have a time that doesn't fit anyone and I will have to convert it upon each page request, to the time of the user in their own timezone. Would you suggest asking the user what their time zone is and store it in the database or try to gather the information from their browser? What about daylight savings?
I'm just hoping for some input from some of you professionals. 🙂
The second question:
I recently joined Facebook and I like how you can view your page and see updates from your friends. The status page may tell you that one of your friends became friends with someone, or that they uploaded some new pictures (and even show thumbnails in the status update) as well as other things like if someone left them a comment, or if they joined a group, etc. It makes it easy to follow what your friends have been doing on Facebook without having to visit each of their profile pages.
I'm trying to think of the best way to incorporate such a technique into my social network and I'm really not sure what the best way to record status updates.
One way may be to add a function call to the end of every existing function that performs an action that I would like to be shared such as pictures uploaded, two people becoming friends, posting a blog, etc. Once each action is performed I can stick a record of that action into each friend's profile somehow so that all of that person's friends have the status update and it can be seen on their profile. The problem with this method is if you have a few thousand members with a few hundred friends, the table rows will really really add up quickly!!!
Another way may be to just query the database. In other words if I go to view my profile, there should be a query that checks all my friend's updates and shows the appropriate ones on my own profile. This way we won't be racking up table rows, however it may really slow down the server performing queries on all of my friend's statuses. There may be some more ups and downs to both of these methods and maybe even a better method than these two. I also want to think of the future when I begin to add more features such as allowing user's to choose whether or not to publish the activity to their friend's profile's or not, as well as the ability to allow them to delete the activity listing from their own (and their friends') profiles. If I just query existing activities from friends, it may be difficult to remove activity entries, as well as give the option for users to publish or unpublish these updates from their friend's pages. How would you say Facebook does it? 🙂
Thanks guys!
Chris