Convert American date format to European and vice versa

This PHP script came up in a discussion I had today with Jon Whitlock, who’s from the other side of the pond (U.K.) It’s a nifty little regular expression that converts an American date (12/31/2006) into a European date (31/12/2006). It struck me as a neat little snippet that others could probably use.

Updated Code

As Scott mentioned in the comments, I have changed the snippet to put quotation marks around the second regular expression.

print ereg_replace(“([0-9]+)/([0-9]+)/([0-9]+)”,“\2/\1/\3“,$date);

As he described it, the first section of the ereg_replace statement takes the date and places it into three variables, 1,2,and 3. It then places those variables into a new string in the 2/1/3 pattern. That makes this a round trip function. Your European dates can get converted back to Yankee days as well.

Set up PuTTY to SSH into Dreamhost accounts

I am working on a new page and needed to install the XML_RSS PEAR script yesterday on my Dreamhost Account. I tried the customer support and went to their twiki. Dreamhost supplies a basic set of PEAR functions and you have to create a new folder and upload any extras that you’d like to use. Normally, I’d quit at this point and try something else. I hate the command line. It gives me heeby jeebies. If I can’t do something with a mouse, I’m quitting.

But, in the spirit of learning new things, I persevered. I installed PuTTY ( on my desktop and began the effort of logging in and updating the server. (PuTTY is a simple program that allows you to establish SSH connections with a server) Alas, it was a no-go. I couldn’t establish a connection. At this point, I do what is normal for a front-end engineer. I fired up the Yahoo! messenger and sent plaintive cries to the back-end engineers that seemed to be online for help. Unfortunately, they had just left their computers running and were nowhere to be seen.

So, back to the Dreamhost twiki. Luckily, their SSH documentation links to a really great blogpost by Phile Planet. This tutorial on How to setup SSH on Windows XP walks you through the process step-by-step. It even predicted that one step may not work for me and offered the workaround.

Logging in

I was able to login at this point by going to the command prompt, typing plink and entering my username and password (Dreamhost people: it’s the FTP username/password). I don’t know why the original tutorial went further to do something else but if it doesn’t work for you, try doing the extra step

  • Go back to the command prompt and type pageant. Double-click on the computer wearing a hat when it pops up in your system tray
  • Click Add Key and go to where you stored that private key. Double-click it and enter your password for the key if you made one earlier
  • Now go to the command prompt and type plink
  • Enter your username and it should just login from there

That’s about it. Here are a few links with stuff you can do in the Shell

Take a look at this tutorial if you are using Dreamhost, or any host for that matter, and Windows XP. It will take you about 15 minutes to set up PuTTY on your machine and hook it into the Dreamhost servers. You’ll never know when you need something like this and it’s nice to know that you’ve already got it setup ahead of time.

Comfort – the death of creativity

I had an art teacher, Walt Cotten, that would remind us to not get comfortable with our medium. As soon as that happened, our images would become stale and our creativity would plummet. He’d encourage us to throw our existing styles to the wind and try something completely different.

I’ve gotten comfortable with CSS. It’s like walking and chewing gum. I don’t check CSS Zen Garden every day for the latest design. I don’t seem to have the time to experiment with new CSS3 techniques. I’m getting stale.

So, what do I do? I’ve been working heavily in CSS, XML, and XSL for the past two years. It’s time to do something new. I’ve dabbled in adapting other people’s php code. I’ve dabbled in handheld style sheets. I’ve dabbled with RSS feeds and a million other things. My goals this year are to break into some new paths. I’m going to start building php pages from scratch, play around with Flash lite and other mobile applications, and delve into Internationalisation.

I’m starting from scratch with PHP. As soon as I finish my first project, I’ll document it on this site for the other CSS people out there looking for the base level tutorials. I know the frustration of asking for advice and having a PHP coder say “It’s easy, setup a parser, blah, blah blah……. and that’s it!”

Latest releases

I’ve been a busy camper this year. Sometimes it seems like I’m so deep in code that I can’t enjoy the fun, creative aspects of web development. However, I have seen a couple sites launch that I’ve had the pleasure of working on.

Yahoo! Food

When I heard Yahoo! was building a food site, I thought Hot Diggity Damn. I want to work on that one. However, I was deeply committed to an important post-launch facelift of Yahoo! Tech. So, I told the Food team that I wanted to help as much as possible. This is a really nice site, with a great leader. The site, from the very beginning, had a distinct character and huge ambitions. Programming the code was nothing compared to what the project managers did for the content.

I was only able to help with some of the early templates and platform settings. The Food team deserves tons of credit for putting together a great site in an amazingly quick time.

Eden Floral Designs

Eden Floral DesignsWhen I came to Yahoo!, I knew very little about PHP and XSL. I was anxious to learn the languages and have gotten pretty darn good with XSL. PHP, however is still a new language for me. My friend Pam asked me to help her build an e-commerce site for her new floral business back in early summer. I told her I couldn’t do it but would look around. Soon enough, I realized this was a good time to jump knee-deep in PHP and learn how to use it. We grabbed a pre-packaged cart sytem, enlisted a friend, Marc, to do the secured server settings, and off we went.

X-cart is robust, but fairly easy to work with. It’s PHP and Smarty based. I spent several weeks replacing tables with standards-based markup, editing the CSS, updating the JS, and adding Pam’s unique visual statement. It’s a pretty site with lots of white space and no rounded corners, my pet peeve.

I still have some validation errors to fix, some legacy code to cleanup, and some cross-browser fixes. But for just the two of us, this site came out pretty dang nice. If you are looking for a San Diego Florist, check out the site. If you are looking for an e-commerce platform, take a look at X-cart. This site took about 200 hours to transform and build. That’s not a small amount, but I considered it a learning experience and didn’t mind a bit.

Coming Up

I’m working on a new project at Yahoo! that is coming along great. In this world of bloated Web 2.0 web sites, this is a lean, mean fighting machine. It is blazingly fast and perfectly suited for its audience. You’ll have to wait a few more weeks for the announcement.