Facebook Cookbook - Jay Goldman [67]
To display a different time, use the PHP mktime() function, which generates the epoch seconds for any given date:
The parameters, in order, are hours, minutes, seconds, month, day, and year. More info is at http://www.php.net/manual/en/function.mktime.php.
Note that fb:time makes the time display relative, so if t is on the same day as today, you’ll just get the time (e.g., 5:35 p.m.); if it’s in the same year, you’ll get month, day, and time (e.g., April 26 5:35 p.m.); and if it’s in a different year, you’ll get the full thing (e.g., April 26, 2008 5:35 p.m.).
You can also include a time zone in your call to fb:time if you want to specify where and not just when:
That would format April 26, 2008 at 5:35 p.m. in the Mexican state of Chihuahua, rather than inside a small, yappy dog. This won’t include the time zone in the display, so you’d need to add it to the end (MST or MDT for Chihuahua, depending on whether daylight saving time is active). The tz parameter accepts any standard PHP time zone descriptor (you can find the full list at http://ww.php.net/manual/en/timezones.php).
Finally, you can pass in a preposition boolean to indicate whether you’d like “at” and “on” inserted into your date. For example:
will give you:
at 5:35pm on April 26, 2008
Making Content Visible to Some Users in Profile Boxes
Problem
I’d really like to make some of the content in my Profile Boxes visible to only a select group of users.
Solution
The fb:visible family of tags will do exactly what you’re looking for. Think of them as the big, burly bouncers who stand inside the velvet rope and won’t let you into the club unless you’re on the magic list. In this case, their clipboards actually contain eight different lists:
fb:visible-to-owner
Content that is visible only to the owner of the Profile.
fb:visible-to-user
Content that is visible only to the specified users. Include a uid parameter containing one or more comma-separated Facebook uids to control who can see it.
fb:visible-to-app-users
Content that is visible only to users who have also added the app and have agreed to the Terms of Service and been granted full permission.
fb:visible-to-connection
Content that is visible only to friends of the user who owns the Profile, or fans of the Page if used on a Page. Note that this effectively replaces fb:visible-to-friends, which worked only on user Profiles.
fb:18-plus
Content that is visible only to users who are 18 years old or older. Unlike the rest of the visible tags, this one and the fb:21-plus tag can both contain an fb:else tag (which displays alternate content) and can be used on Canvas pages.
fb:21-plus
Content that is visible only to users who are 21 years old or older. As per the previous tag, this can contain an fb:else tag to display alternate content to people who are under 21.
Discussion
All of the previously listed tags will accept an optional bgcolor parameter, which lets you set the color of the block shown to users who don’t meet the criteria. Let’s say that you were going to include an encouragement to friends of your users to kick back and hang out with their friends, but you didn’t want to encourage anyone under 21 to have a drink:
Have a drink with your friend! Have a pop with your pal! Users who are friends with the Profile owner and over 21