Iso 8601 date format Output Modifiers

Hello, I’m working with an API, the timestamp os iso 8601 (2019-05-30T20:35:00-04:00)
I got that data into a placeholder, is there any way that I can modify the result with a ModX Output Modifier? I need something like: Th 30 05 2019.

I know it’s possible with Unix timestamp but not sure about this one.
thanks!

The strtotime output filter can be used to turn such a date into a unix timestamp, which you can then format with the date output filter.

E.g.:

[[+placeholder:strtotime:date=`%Y-%m%d`]]

2 Likes

Thanks Mark for your help but it’s not working.
here more details:

I got this API url, I’m using simplx_widgeteer (if there is something better to do that please let me know) to process the data and use placeholders to display what I need.

One of the placeholders is [[+mydate]] that is displaying this: 2019-05-30T20:35:00-04:00
everything ok and all the other data is fine.

Now I need modify the format, I thought “strtotime” might help but if I use it:

[[+mydate:strtotime:date=`%Y-%m%d`]]

everything disappear, it doesn’t display anything.
can you please guide me for the best way to do that?

I’ll need the date and the time in two different places.
cheers mate!

What do you get if you just do this?

[[+mydate:strtotime]]

I’ve not personally used simplx_widgeteer so can’t really speak to its qualities, but I don’t think there’s a lot of other parse-random-api-into-placeholders plugins available.

Just disappear, it’s gone :sob: haha.
what do you recommend? do it manually via php?

Fixed (manually).

Just using a snippet:

<?php
$data = json_decode( file_get_contents("url_here"), true );
for ( $i=0; $i<count( $data ); $i++ ){
    $date = $list[$i]["date_here"];  //<== 2019-05-08T13:31:13-04:00
    $fixed = date('l d F Y', strtotime($date));
}

This print: Friday 31 May 2019.
Cheers!!

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.