The PHP strtotime function seems to be behaving oddly when used in conjunction with Zend_Feed, consistently displaying

An issue arises with Zend_Feed always updating the publish date to the current date and time.

foreach($array['rss']['rows'] as $row) {
    try {
        $pubDate = strtotime($row['from']['value']); 
        $entry = array(
            'title'       => "{$row['title']['value']}",
            'pubDate'    => "{$pubDate}",
            'link'        => "{$url}news/item/{$row['uri']['value']}",
            'description' => "{$row['content']['fvalue']}"
        );

        array_push($this->entries, $entry);
    } catch(Exception $e) {
        throw($e);          
    }
}   

$rss = array(
    'title'   => 'News',
    'link'    => $url,
    'description' => 'Latest News Articles',
    'charset' => 'ISO-8859-1',
    'entries' => $this->entries
);

$feed = Zend_Feed::importArray($rss, 'rss');
$feed->send();

The format of the 'from' value is like this 2012-05-07 00:00:00. A var_dump of the $rss array just before it's passed to Zend_Feed reveals:

array(4) {
  ["title"]=> string(44) "International Horse Trials"
  ["link"]=> string(31) "http://www.horse.co.uk/"
  ["description"]=> string(78) "Location: Wetherby "
  ["pubDate"]=> string(10) "1339023600"
}

Various attempts have been made to adjust the date format.

$pubDate = gmdate(DATE_RFC822, strtotime($row['from']['value']));

Answer №1

The incorrect variable is being utilized:

'lastModified' => 'time the post was updated',

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What are the potential ways in which an html IMG tag can disrupt the functionality of this

For years, I have been using this form code without any issues. The code functions perfectly and all the tags are correct. However, whenever I include an image tag, it displays a failure message and prevents the mail function in PHP from working. The hea ...

The "Symfony QueryBuilder" is an outstanding tool

I'm creating a website that showcases various projects with a menu. This menu allows users to filter projects by language. However, I'm facing an issue with the query to retrieve projects for a specific language. I have two entities: Project and ...

Why is the PHP MySQL result showing up twice?

Having an issue with my PHP script that is fetching results from the localhost WAMP server. When I print out the query, each record is being displayed twice! Check out the screenshot below for a visual representation: This is the PHP MySQL script: <? ...

Searching for multiple lines of text within a PHP document

Recently, I have been working on a project that involves an addon making modifications to a crucial system file. As part of this task, I have created a method to locate specific strings within the file: /** * @param $fileName * @param $str ...

Tips for retrieving return values from an ajax form submission

When using ajax to submit a form, I encountered an issue where the process would halt at api.php and not return to the ajax success. Below is the code snippet: <form method="POST" id="form_1" action="../api.php" enctype="multipart/form-data" novalidate ...

Laravel issues with displaying data in a 'foreach' loop

I encountered a quirky issue while working with Laravel 5.2. I have a chunk of text that I'm attempting to display using some explode functions. The strange part is, Laravel is rendering it oddly by adding incorrect ':' before the end of the ...

Uploading files with Laravel through Ajax

I am currently facing an issue while trying to upload files using Ajax and Laravel. Whenever I attempt to upload a file, it returns empty. The following is the method in Laravel: public function save_vehicles(Request $request){ $files=$request->fil ...

Access-Control-Allow-Origin does not permit the origin null

I've been searching for an answer to this question, but I haven't found a suitable one yet. let xhr = new XMLHttpRequest(); xhr.onreadystatechange = function(){ if(xhr.readyState === 4 && xhr.status === 200){ let response = r ...

Issue with Symfony 4: @ParamConverter annotation unable to locate object in Profiler exclusively

The issue is specific to the debug toolbar. Highlighted below is the code section I suspect might be causing the problem /** * @Route("/{category_slug}/{slug}", name="content_show") * @ParamConverter("content", options={"mapping": {"slug": "slug"}} ...

Is it possible to execute PHP without using Ajax when clicking on a Font Awesome icon?

So, besides using Ajax, is there another solution to achieve the same result? Can a font-awesome icon be turned into a button without Ajax? In case you're unfamiliar with what I mean by a font-awesome icon, here's an example: <i id="like1" on ...

Enabling drag and drop functionality for elements in Yii2

I am looking to create draggable elements in a Yii2 advanced application. I have tried using PHP and HTML examples similar to http://jqueryui.com/draggable, but so far it has not been successful. Can anyone provide assistance? Below is the code from the vi ...

Storing an image in a file using PHP

After generating a graph using PHP and saving it as a PNG file with the given code, I have a query. How can I save the image for download instead of displaying it on a web page? Your assistance in guiding me through this process would be greatly apprecia ...

Ways to extract an object from JSON into PHP

Can someone help me figure out how to extract an image link from this API ()? The API endpoint is https://en.wikipedia.org/w/api.php?action=query&prop=pageimages&format=json&piprop=original&titles=Minecraft&pilicense=any. I've tri ...

Error catcher

I'm working on developing an exception handler that needs to deal with five different types of exceptions, which I'll refer to as Ex1, Ex2, Ex3, and so on. My initial thought was to create a single class called ExHandler and instantiate it like ...

What is the best way to understand and interpret the decoded JSON array data?

I'm finding it challenging to interpret this JSON decoded array. It's more complex than what I usually work with, so any assistance would be greatly appreciated. Thank you in advance. array(1){ [0]=> object(stdClass)#1 (11){ ["id ...

What is the best way to utilize silex's "finish" middleware for efficiently handling resource-intensive tasks in the background?

Currently, I am creating an app using Silex and following the documentation with some additional features. I have set up the route, added middleware for the route, and included finish middleware for the app. $app->put('/request/', function (R ...

Switch up the position of an element every time the page is refreshed

I have a webpage containing 5 images, each measuring 48px by 48px. I would like these images to be displayed in random positions on the page every time it is loaded. While I am aware that I will need to use CSS and JavaScript for this task (specifically f ...

Unable to retrieve file from Alias directory using the download script

Currently, I am developing a download script. The PHP files are stored in the xampp htdocs directory, while the folder containing the actual files is on an external HDD. An Alias has been configured for the external drive: <Directory "h:/Filme"> Op ...

Issues with jQuery autocomplete when using special characters (Norwegian)

On my website in Norway, I am facing an issue with jQuery's autocomplete function. When users type in the Norwegian characters æ, ø, and å, the autocomplete feature suggests words with these characters within them but not ones that start with these ...

Sort out the table using Javascript and then choose all the checkboxes

I'm struggling with a function in Javascript that will only check checkboxes on visible rows of an HTML table. The table has a checkbox on each row and is filtered based on a textbox above the table. The checkboxes in the table are named chkbuild, an ...