Date Formatting headaches with Timezones
This is an open discussion with 4 replies, filed under General.
Search
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="http://php.net/xsl" 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.
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 thetime-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?