Jump to content


Member Since 23 Apr 2006
Offline Last Active Oct 29 2015 10:53 PM

Topics I've Started

Timezone Syncing

14 April 2012 - 02:44 AM

Developing apps is great until I have to start dealing with blasted timezones. For some reason this aspect of it always does my head in.

At the moment I'm storing all dates in the DB as GMT with the format Y-m-d H:i:s. I figure it's good to be consistent and store dates in GMT then convert to the users desired timezone. So I allow users to choose there timezone, based off the defined PHP timezones that can be used with the DateTimeZone class.

My problem, however, arises with the whole syncing of times. Let's say I post something right now. The date gets stored in in the database as: 2012-04-14 02:35:49
Now I'm in GMT +10 (possibly the greatest of timezones :)), so I've set my timezone in my settings as Australia/Melbourne and when displaying date/times locally I do something like this:

public static function local($user, $date, $format = 'F j, Y, h:ia')
	$date = new DateTime($date);

	return $date->setTimezone(new DateTimeZone($user->timezone))->format($format);

So running the stored date above through my method gives me a date like this: April 14, 2012, 12:35pm


My question is: I noticed that on say, Twitter, when you change your timezone your tweet dates don't change. They remain as the date/time of my actual timezone, regardless of what I set it too. With my implementation however, if I change my timezone to GMT +12 (Fiji) my post is now posted at: April 14, 2012, 02:35pm

So is what I'm doing right? My head has about had it.


NodeJS + socket.io + PHP to achieve real-time notifications

19 March 2012 - 09:14 AM

I'm looking for advice at the moment on achieving real-time notifications using a mix of PHP, NodeJS and socket.io.
At the moment I have done next to nothing with Node and socket.io so I'm at a loss with the best way to achieve this. I've done some basically listening and what not but nothing extreme.

For now my questions are:

1. How will socket.io know of new notifications, should PHP be responsible for sending the data (say a post was created) to socket.io and from there broadcasting to connected clients?
2. How does socket.io know which clients want the notifications?

I'm really not sure what else. This is all a bit much for me at the moment. I just can't get my head around how the notifications will be distributed.

Any advice would be greatly appreciated. I don't expect a detailed walk through, just a push in the right direction or some knowledge on how it all meshes.


Hamish & Andy - Bin Racing

28 August 2011 - 10:24 AM

For those of you who don't know, Hamish and Andy are an Australian radio hosting duo. They're really funny guys. Currently they are on a GAP year in New York, that clip is from an episode of their currently airing TV show. Funny stuff. :)

This is safe for work too.

Best way to handle dynamic form data.

28 August 2011 - 05:40 AM

This relates to Ajax as well but more-so JavaScript.

Let me use an example. I have a tagging system that's using Ajax to auto-suggest tags. The user can then select a tag from the suggested tags or add the tag they want. If they select a tag, is the best way to go about it adding that tag ID to a hidden field as a comma separated list. Or... keep the selected tags in an array and attach an event to the submit handler of the form, then once submitted insert X amount of hidden inputs (where X is the number of tags) so that I'll have an array of selected tags when they submit.

In the past when I've done things like this I've just updated a hidden input each time a tag is added/edited, however I'm just wondering if the second approach is possible and if it's better. The only possibility I can think of is that it won't work due to the form already being submitted and thus the inputs aren't actually added to the post data. I am yet to test this.


Detailed login error messages.

27 August 2011 - 02:13 PM

Was having a discussion with a friend about logins, since I was developing mine to determine which of the credentials was incorrect to inform the user that they got the password wrong.

Is this security issue? My friend seemed to think so.

The way I thought of it is, they'll probably know your username anyway. Like people here will know what my username is from looking at my, well, username (although my display name was changed recently, mwhaha!). So telling them that they specifically got the password wrong if they logged in incorrectly with my username isn't going to mean anything, right? That's my thinking. I personally like seeing a more detailed message, as on various sites I go by jaysonic, or jaysonic1991 (if jaysonic is taken) and sometimes even jaysonic91 (I don't know why...). So when I login and it says "Your username or password was incorrect" I curse them silently because I don't know which! Since I also have a few various passwords this makes it somewhat annoying sometimes.

Long story short. Are detailed login error messages (specifically stating which credential was wrong) a security issue?