Click here to get back home

how to change the date format of all my htmls?

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
how to change the date format of all my htmls? robertchen117@gmail.com 06-07-2008
Posted by robertchen117@gmail.com on June 7, 2008, 11:31 pm
Please log in for more thread options
I have many html files in my directory, I want to change all date with
dd/mm/yy format to /mm/dd/yyyy in the files.

Please let me know how to do it in perl...

thanks

Posted by RedGrittyBrick on June 8, 2008, 8:26 am
Please log in for more thread options
robertchen117@gmail.com wrote:
> I have many html files in my directory, I want to change all date with
> dd/mm/yy format to /mm/dd/yyyy in the files.
>
> Please let me know how to do it in perl...
>
> thanks

On Unix something like
perl -p -i -e 's|(\d\d)/(\d\d)/(\d\d)|"$2/$1/".($3<50?20:19).$3|eg' \ *.html

As I expect you know, on MS Windows you have to use -e'' instead of -e""
which means I usually change the inner "foo" to qq(foo).

--
RGB

Posted by Tad J McClellan on June 8, 2008, 10:21 am
Please log in for more thread options

> I have many html files in my directory, I want to change all date with
> dd/mm/yy format to /mm/dd/yyyy in the files.


Should 01/01/01 result in 01/01/1801 or 01/01/1901 or 01/01/2001 or ...


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher0cmdat/"

Posted by Gunnar Hjalmarsson on June 8, 2008, 10:55 am
Please log in for more thread options
robertchen117@gmail.com wrote:
> I have many html files in my directory, I want to change all date with
> dd/mm/yy format to /mm/dd/yyyy in the files.

Wouldn't it be better to change them to the non-ambiguous international
standard format yyyy-mm-dd

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Similar ThreadsPosted
To change the time stamp format... April 2, 2005, 10:01 am
Change date on-the-fly October 17, 2007, 6:42 pm
date format October 18, 2004, 9:43 am
date format July 5, 2006, 3:08 am
Date format July 23, 2008, 6:34 pm
The best way to parse a date in a known format August 29, 2004, 12:29 am
Date format in perl September 9, 2004, 10:02 am
Date format conversion May 30, 2006, 9:37 am
Change file creation date? December 22, 2004, 6:40 pm
what is a good/fast way to format date string? March 6, 2006, 1:58 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap