I hate dates and times, especially in XSLT. Just putting that out there first ;o)

So, I have a client in Chicago and their Symphony setup has the timezone correctly set so that the parameters all come through correctly for their location.

All is good until we pull in feeds from Twitter and Facebook. Twitter is sending it's data through as +00:00 and Facebook as +01:00.

I'm trying to get these feeds to display correctly on the front end as 1 hour ago or similar using the time-ago.xsl utility.

The problem I have is that firstly I have to translate the RFC date format into ISO, which I have a little utility to do this with, then pass that ISO date into the time-ago.xsl utility, which completely ignores the timezone adjustment.

So the output invariably is 4 hours from now which as you can imaging is really pissing off the client.

I've tried to solve this loads of times over the project lifespan, but keep coming up blank. I've tried all of the date formatting utilities available here, also read about the exslt functions which just completely confuse me.

Can anyone help me here?

Well, I got it fixed, what a ball ache.

I've had to create another template to flatten all ISO dates into GMT0 (UTC) dates. I will post it later if I remember.

This is probably cheating but I set up an extension that has a few PHP date/time functions in it that I use when required.

Not sure how relevant it is here but I looked briefly into date formatting with XSLT and I either gave up or got a headache.

nathanhornby, which extension?

I will post it later if I remember.

Classic. I should append this to all of my posts :-)

Lewis - Just a super basic extension I added for my own needs. I'd be happy to share it but I wasn't 100% sure it was the best way to achieve what I was doing - so didn't want to perpetuate it :)

The main thing it's used for is re-formating dates from things like Twitter feeds and blog articles to something consistent.

<xsl:value-of xmlns:php="" select="php:function('formatdate', date)"/>

That'll just run through a standard PHP date() format. Far easier than the big chunk of XSLT I found to do the same job.

But as I say, I wouldn't feel comfortable recommending this as a technique… correct me if I'm wrong.

[EDIT] tl;dr: It's a cheating extension I use as a crutch to transition from PHP to XSLT.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details