PHP date() function usage and examples

I have been coding PHP like for almost 10 years. The date() function in PHP is a widely used function in most of my apps. The application or website I’m developing will require to associate with a date at some point. When displaying a date/time it requires to be displayed in a particular format. This will be different from one app to another. So remembering each format character is quite difficult even thought I have 10 years of experience on my back. So each an every time I head to the PHP: date() Manual to find out the format character. I have had cheat sheet wallpapers as my desktop wallpaper but I still felt the PHP Manual served me better. But finally I decided to build my own reference with commonly used character combinations with their respective output to make my life much easier (not that it was difficult before) so that other PHP developers will benefit out of this as well.

<?php
#The two example outputs are based on this time
#eg1: 2010-06-19 15:09:35
#eg2: 2010-06-19 08:30:59

echo date("Y-m-d");
#Output eg1: 2010-06-19
#Output eg2: 2010-06-19

echo date("n/j/y");
#Output eg1: 6/19/10
#Output eg2: 6/19/10

echo date("Y-m-d H:i:s");
#Output eg1: 2010-06-19 15:09:35
#Output eg2: 2010-06-19 08:30:59

echo date("l, jS F Y h:i a");
#Output eg1: Saturday, 19th June 2010 03:09 pm
#Output eg2: Saturday, 19th June 2010 08:30 am

echo date("jS M y g:i A");
#Output eg1: 19th Jun 10 3:09 PM
#Output eg2: 19th Jun 10 8:30 AM

echo date("D, j M Y G:i:s");
#Output eg1: Sat, 19 Jun 2010 15:09:35
#Output eg2: Sat, 19 Jun 2010 8:30:59

?>
Share and Enjoy:
  • Twitter
  • Facebook
  • Digg
  • del.icio.us
  • FriendFeed
  • Google Bookmarks
  • Technorati
PHP, Technology

WordPress 3.0 “Thelonious” released

It’s the moment that most of the Wordpress enthusiasts were waiting for. The release of Wordpress 3.0 bring lots of new features and updates that makes Wordpress a powerful CMS to build complex and powerful websites.

Arm your vuvuzelas: WordPress 3.0, the thirteenth major release of WordPress and the culmination of half a year of work by 218 contributors, is now available for download (or upgrade within your dashboard). Major new features in this release include a sexy new default theme called Twenty Ten. Theme developers have new APIs that allow them to easily implement custom backgrounds, headers, shortlinks, menus (no more file editing), post types, and taxonomies. (Twenty Ten theme shows all of that off.) Developers and network admins will appreciate the long-awaited merge of MU and WordPress, creating the new multi-site functionality which makes it possible to run one blog or ten million from the same installation. As a user, you will love the new lighter interface, the contextual help on every screen, the 1,217 bug fixes and feature enhancements, bulk updates so you can upgrade 15 plugins at once with a single click, and blah blah blah just watch the video:) (In HD, if you can, so you can catch the Easter eggs.)

Source : http://wordpress.org/development/2010/06/thelonious/

Share and Enjoy:
  • Twitter
  • Facebook
  • Digg
  • del.icio.us
  • FriendFeed
  • Google Bookmarks
  • Technorati
PHP, Technology, Wordpress

Refresh Colombo

refresh-colombo-header

A bunch of tech enthusiasts have got together in organizing a meetup for the techy/geeky crowd in Colombo. It was organized in quick time and is scheduled to take place this Thursday. Its totally an informal meetup where we get to share our ideas. Most of the sessions will be much similar to a Lightning Talk. Though few topics have been chosen already, anyone will be welcome to do a lightning talk related to technology. The event is open to public and entrance is free. But your RSVP on the FB event page will help the organizers to get a head count as the seating is limited. So do drop in to meet individuals who think and act like you ;-)

Refresh Colombo

Refresh Colombo is a community of web and technology enthusiasts/professionals who come together on a monthly basis to share ideas and meet like minded individuals.

Refresh Colombo events are open to the public. We encourage you to bring a friend or two. Hackers, bloggers, coders, geeks & geek lovers, journalists, techies, entrepreneurs and venture capitalists are all welcome – you can even bring your grandma.

This month’s presentations :

Samir Husain – CEO of Cenango USA will be presenting on “Transforming Sri Lanka into ‘Silicone Island’ – Asia’s IT innovation hub”

Buddika Siddhisena – FOSS evangelist will be presenting on “The Open Source Opportunity”

Aloka Gunasekara – SEO Specialist will be presenting on “Introduction on Search Engine Optimization”

Indrajit Samarajiva – Creator of kottu.org will be presenting on “Blogs and Social Media”

WHEN - June 17, 2010 at 5:30PM

WHERE - The Ceylon Chamber of Commerce ( No. 50, Navam Mawatha, Colombo-02. Sri Lanka )

For more information Contact Milad – 0772257225 or Email info@refreshcolombo.org
Visit our website at http://www.refreshcolombo.org/

Share and Enjoy:
  • Twitter
  • Facebook
  • Digg
  • del.icio.us
  • FriendFeed
  • Google Bookmarks
  • Technorati
Events, FOSS

It’s that time I start playing football

It’s that time once in four years I start playing football instead of cricket. Football has never been my game, but when the Football World Cup fever gets to me, my feet auto-magically starts kicking the ball around the park. The 2010 FIFA World Cup starts on the 11th June which is like couple of weeks away. The heat has got on to all the football fans already. Even the people who have less interest in football have felt the heat after listening to the version of  “Wavin’ Flag” (The Celebration Mix) by K’Naan which has become quite a hit these days . Let it be on radio stations or even in the ring tones of mobile phones, you will hear it where ever you go. The funny thing is its not the official song, but it has reached the people and fans alike since this year’s World Cup will be played in South Africa and this version of Wavin’ Flag inspires the celebrations familiar to Africa.

Wavin’ Flag by K’Naan

There is another version of Wavin’ Flag which was remade by a group of Canadian artists credited as Young Artists for Haiti to benefit the relief efforts following the 2010 Haiti earthquake which is much similar to “We are the World for Haiti” done by popular artists around the world.

Wavin’ Flag by Young Artists For Haiti

Share and Enjoy:
  • Twitter
  • Facebook
  • Digg
  • del.icio.us
  • FriendFeed
  • Google Bookmarks
  • Technorati
Football, Sports

Eoin Morgan: Mastering the Reverse Sweep

During the 90’s when One-Day cricket was at its peak different batsmen tried to be innovative to score runs with each an  every possible opportunity. The reverse sweep was one of them. While I cannot recall who really innovated this stroke, during the 90’s and early 2000 Damien Martyn, Jonty Rhodes and Andy Flower are few batsmen who come to my mind who mastered this stroke to score some quick runs. When Twenty20’s became popular in the late 2000, a few more innovative shots were tried by the batsmen. Kevin Pietersen’s switch hit became quite popular as a modified reverse sweep. Reverse sweeping Murali for a six using his switch hit during a Test match was the biggest moment for Pietersen. Couple sixes he smashed with his switch hit against Scott Styris in an ODI was the best I have seen him play that shot. But now the Irish-born Englishman, Eoin Morgan is mastering the art of reverse sweeping with his unique style of batting.

Morgan played this reverse sweep against Rampaul when England took on West Indies few days ago in the T20 World Cup. Look at this for a shot.

Digged more on this and found out this clip. A collection of Morgan’s reverse sweeps while playing for his county.. Will he be the king of reverse sweeps?

Share and Enjoy:
  • Twitter
  • Facebook
  • Digg
  • del.icio.us
  • FriendFeed
  • Google Bookmarks
  • Technorati
Cricket, Sports

Stats: most runs at each batting position

Came across an interesting question on the Ask Steven column which immediately caught my attention while reading through Cricinfo.com

The question: “Can you give the list of the people with most runs at each batting position in Tests and ODIs?”

And the answer for that question was..

Tests

  1. Sunil Gavaskar (8511 runs)
  2. Matthew Hayden (7351)
  3. Ricky Ponting (9421)
  4. Sachin Tendulkar (11,239)
  5. Steve Waugh (6754)
  6. Steve Waugh (3165)
  7. Adam Gilchrist (3948)
  8. Daniel Vettori (2072)
  9. Daniel Vettori (1075)
  10. Waqar Younis (496)
  11. Muttiah Muralitharan (623)

ODIs

  1. Adam Gilchrist (7720)
  2. Sachin Tendulkar (12,857)
  3. Ricky Ponting (11,979)
  4. Aravinda de Silva (6870)
  5. Arjuna Ranatunga (4675)
  6. Michael Bevan (3006)
  7. Chris Harris (2130)
  8. Wasim Akram (1208)
  9. Brett Lee (557)
  10. Waqar Younis (478)
  11. Courtney Walsh (165 runs; Murali currently has 163)

Source : http://www.cricinfo.com/magazine/content/story/457381.html

This statistic is not quite the common statistics we would normally see. What interested me the most was too see the Sri Lankan veterans Aravinda de Silva and Arjuna Ranatunga taking the No.4 and 5 respectively in the ODI list. Murali has secured the No.11 spot in Tests. Hopefully if he gets another crack in ODIs, he will get the No.11 spot in ODIs as well.

Sachin, Ponting and Gilchrist are there in both lists and deserve very much to be so since they made the best out of their batting position.

Batsmen in the recent past don’t make the cut. But this list is missing some big names coz though they made big runs during their career, they were batting at different positions more often than not. Thats actually the reason why these batsmen standout from the lot.

Will post more interesting stuff when I come across them..

Share and Enjoy:
  • Twitter
  • Facebook
  • Digg
  • del.icio.us
  • FriendFeed
  • Google Bookmarks
  • Technorati
Cricket, Sports

Batch resize/rotate photos in Nautilus

It came as quite a surprise when I figured out that Nautilus, the file manager for the GNOME desktop actually had an extension to resize/rotate photos. I don’t do much post editing after taking photos. If any editing is required, I would normally edit it using an image editor depending on the requirement. But in most cases it doesn’t require me to resize the photos since I upload the originals to my Flickr gallery. But I wanted to upload some photos I took today to Facebook. I didn’t want to upload the originals since it had a higher resolution and the file sizes were bigger. I wanted to resize all the photos in a batch. I had a PHP script that uses GD library for this particular task which I wrote long time back. I have also used Image Magick which works like magic for operations like this. My task was simple and all it required was to resize all the photos in one go and the Nautilus Image Converter just did that with ease.

Installation is quite simple in Ubuntu 9.10

sudo apt-get install nautilus-image-converter

This will install the Image Converter extension to the Nautilus file manager. You will need restart GNOME in order for the changes to apply. If you are using a different distro, I’m sure you will be able to do a Google Search to find out how to install it.

After the installation its all a matter of browsing the folder where you have the photos through Nautilus.

Its one of those coolest apps I came across which does the simple things in a simple way. Love it..!!!

Nautilus Image Converter

Share and Enjoy:
  • Twitter
  • Facebook
  • Digg
  • del.icio.us
  • FriendFeed
  • Google Bookmarks
  • Technorati
GNU/Linux, Technology, Ubuntu

Tweets via SMS: Now active for Sri Lanka

Its official and its big. Now we can receive Tweets via SMS from the people we are following on Twitter. When you go to your Settings / Mobile page on Twitter, now you will see Sri Lanka as a country, thanks to Dialog. If you look closely there are only a few more countries has this feature enabled. Further more, posting an update to Twitter via SMS gets a boost as well. Now you don’t need to send your Tweets to the Twitter long code which is similar to sending a message to an International number which in cost wise is expensive. Now you can send your updates to the Twitter short code from your Dialog mobile which will be charged same as sending a SMS to a local number. There won’t be any charges for receiving updates via SMS. Twitter on your Mobile page has all the info about how you can activate this feature on your Dialog mobile. If you used to update Twitter via SMS using the Long Code/International number, you won’t need to do much of the changes mentioned in that page.

Most importantly you won’t receive updates to your mobile from all the people you are following. I really can’t imagine how scary that would be. You will need to set the option to receive updates via SMS to your phone from the person you are following on Twitter. Twitter Phone FAQs has all the answers to your questions. Check how To Turn Mobile Updates On and Off (via Web or SMS) page to subscribe/unsubscribe to receive updates via SMS.

When I joined Twitter in 2007, we had the option to send and receive updates to Twitter via SMS through the International number (long code). But when time moved on and more people joined, Twitter limited this functionality by allowing short codes only to few countries which supported two-way (sending and receiving) text-messaging. Rest of the countries only had the option of using long codes which supported only one-way (sending only) text-messaging.

I’m sure this is a big news to the Twitter addicts in Sri Lanka. This move will also make Sri Lankans to start using Twitter  in a more fun and efficient way. The Official Twitter Text Commands page will be guide you to get going.

While I have most of my friends on Twitter and have also have got connected to new people, some of my friends actually don’t really get it. For them Twitter is less interactive than Facebook and most of the time they get confused with the two. A lot of them join Twitter and post updates for a couple of days and thats it. They go missing completely. In my opinion Twitter and Facebook have two different models and they must choose one or use both in a selective manner to serve their purpose. Facebook is a way to communicate only within your friends you know on a close environment but Twitter can be used to communicate to the rest of the world. Search Engines and other tools pull off your Tweets and do wonders with it while Facebook model doesn’t allow this. Twitter too has protected accounts but it really doesn’t serve the whole purpose of using Twitter. So as I said earlier, it all depends on how you use these services to serve your purpose.

Here is a video that explains the whole Twitter thing in plain English. Hopefully it will encourage few of you to start Tweeting.

Share and Enjoy:
  • Twitter
  • Facebook
  • Digg
  • del.icio.us
  • FriendFeed
  • Google Bookmarks
  • Technorati
Social Media, Technology

lkgeeks.org back with new looks & ideas

logo

When I planned to revamp lkgeeks.org some where around the end of last year, I wanted to make it happen within a month. But things got bit dragged and new ideas came in and now I have almost taken it to the next level. The website has been re-launched. You can check the site out at www.lkgeeks.org. There is a dedicated Twitter account and a Facebook fan page to connect all the Sri Lankan geeks. A new Twitter List has been created, so the Twitter Feed on lkgeeks.org will be based on this list.

While the initial idea of aggregating the blog posts and tweets of Sri Lankan geeks still remains, lkgeeks.org will provide more interaction among the geeks in Sri Lanka. From being connecting everyone virtually, it has gone a step further up by trying to get all of them physically together to share knowledge and experience. While this is a challenging task, lkgeeks.org has taken up this challenge to arrange workshops/meetups which will be free or at an affordable price (to cover the cost).  The workshops will be conducted by our own local experts in their relevant field. The topics will be based on the latest emerging technologies which will be a great way for the Sri Lankan geeks to start adopting to it. Topics/date/time/venue will be announced soon.

So keep checking the website, follow lkgeeks.org on Twitter and become a fan on Facebook to be first informed. Let me know your thoughts and comments as it will help in a great deal to improve on what I have built so far.

Share and Enjoy:
  • Twitter
  • Facebook
  • Digg
  • del.icio.us
  • FriendFeed
  • Google Bookmarks
  • Technorati
Events, FOSS, Technology, Web

Boom Boom McCullum

I have been looking around for the highlights of Brendon McCullum’s hundred against Australia in the 2nd T20 match in the current ongoing series and have finally found it. When I watched the highlights of this match, I was stunned to see his shot selection against the Aussie pace attack. I was amazed by the number scoops he played over the keepers head against the likes of Shaun Tait who almost bowled the “fastest ball ever” in the recent series against Pakistan. The scoops came mostly in the latter part of McCullum’s innings and the two sixes he scored off the scoops after reaching the century were the best picks.

When Dilshan started to play the scoop against some of the best pacemen during the T20 World Cup, the cricketing world admired his ability and gave the scoop a name and that was the “Dil-scoop”. He stands his ground and makes sure that his head is down while playing the scoop to avoid being hit. He is the best in what he does.

The technique McCullum uses is quite different from Dilshan’s. He completely throws himself away from the line of the ball and plays the shot to make sure that he doesn’t get hit. Some may call this “not-Cricket” but lately we have been seeing a lot of innovative shots being played with the invasion of T20 cricket. Can we call this the McScoop?

McCullum was just the second batsman to score a century in a T20 international. While he was just one run short to beating Gayle’s highest score, he also missed out on scoring the fastest century. He had only faced a ball more than Gayle when he reached the century.

Enjoy the highlights of McCullum’s innings

Share and Enjoy:
  • Twitter
  • Facebook
  • Digg
  • del.icio.us
  • FriendFeed
  • Google Bookmarks
  • Technorati
Cricket, Sports