Jump to content

sitemap displaying wrong date : 1970-01-01


Recommended Posts

Hi Pat,

 

If you get this date, it means the date field is not defined (null).

 

To fix, try this (Didn't test it, but give it a try):

 

edit file /modules/gsitemap/gsitemap.php  (Make backup!!!)

 

You have a function:  (Example code from PS 1.6.0.8):

 

 

private function _addSitemapNode($fd, $loc, $priority, $change_freq, $last_mod = null)
{
    fwrite($fd, '<loc>'.(Configuration::get('PS_REWRITING_SETTINGS') ? '<![CDATA['.$loc.']]>' : $loc).'</loc>'."\r\n".'<priority>'."\r\n".number_format($priority, 1, '.', '').'</priority>'."\r\n".($last_mod ? '<lastmod>'.date('c', strtotime($last_mod)).'</lastmod>' : '')."\r\n".'<changefreq>'.$change_freq.'</changefreq>'."\r\n");
}
 
 
Maybe you can test here to see if the last_mod is null, and if so, use the current time instead:
 
 
private function _addSitemapNode($fd, $loc, $priority, $change_freq, $last_mod = null)
{
    if (empty($last_mod))
        $last_mod ="now";
    fwrite($fd, '<loc>'.(Configuration::get('PS_REWRITING_SETTINGS') ? '<![CDATA['.$loc.']]>' : $loc).'</loc>'."\r\n".'<priority>'."\r\n".number_format($priority, 1, '.', '').'</priority>'."\r\n".($last_mod ? '<lastmod>'.date('c', strtotime($last_mod)).'</lastmod>' : '')."\r\n".'<changefreq>'.$change_freq.'</changefreq>'."\r\n");
}
 
(Question remains, how did it stay empty in the first place...)
 
Let me know if it works,
pascal.
Link to comment
Share on other sites

  • 8 months later...

 

Hi Pat,

 

If you get this date, it means the date field is not defined (null).

 

To fix, try this (Didn't test it, but give it a try):

 

edit file /modules/gsitemap/gsitemap.php  (Make backup!!!)

 

You have a function:  (Example code from PS 1.6.0.8):

 

 

private function _addSitemapNode($fd, $loc, $priority, $change_freq, $last_mod = null)
{
    fwrite($fd, '<loc>'.(Configuration::get('PS_REWRITING_SETTINGS') ? '<![CDATA['.$loc.']]>' : $loc).'</loc>'."\r\n".'<priority>'."\r\n".number_format($priority, 1, '.', '').'</priority>'."\r\n".($last_mod ? '<lastmod>'.date('c', strtotime($last_mod)).'</lastmod>' : '')."\r\n".'<changefreq>'.$change_freq.'</changefreq>'."\r\n");
}
 
 
Maybe you can test here to see if the last_mod is null, and if so, use the current time instead:
 
 
private function _addSitemapNode($fd, $loc, $priority, $change_freq, $last_mod = null)
{
    if (empty($last_mod))
        $last_mod ="now";
    fwrite($fd, '<loc>'.(Configuration::get('PS_REWRITING_SETTINGS') ? '<![CDATA['.$loc.']]>' : $loc).'</loc>'."\r\n".'<priority>'."\r\n".number_format($priority, 1, '.', '').'</priority>'."\r\n".($last_mod ? '<lastmod>'.date('c', strtotime($last_mod)).'</lastmod>' : '')."\r\n".'<changefreq>'.$change_freq.'</changefreq>'."\r\n");
}
 
(Question remains, how did it stay empty in the first place...)
 
Let me know if it works,
pascal.

 

I don't know where to put this

 

"private function _addSitemapNode($fd, $loc, $priority, $change_freq, $last_mod = null)

{
    fwrite($fd, '<loc>'.(Configuration::get('PS_REWRITING_SETTINGS') ? '<![CDATA['.$loc.']]>' : $loc).'</loc>'."\r\n".'<priority>'."\r\n".number_format($priority, 1, '.', '').'</priority>'."\r\n".($last_mod ? '<lastmod>'.date('c', strtotime($last_mod)).'</lastmod>' : '')."\r\n".'<changefreq>'.$change_freq.'</changefreq>'."\r\n");
}"
 

 

 

 

in the file

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...