Reputation: 110970
I'm using the following plugin: http://code.google.com/p/jquery-localtime/wiki/Usage
My elements are rendered on the page with JS so I apply the plugin to the element as follows:
var format = "dd/MM/yy HH:mm a";
var localise = function () {
jQuery(this).text(jQuery.localtime.toLocalTime(jQuery(this).text(), format));
};
jQuery(".localtime").each(localise);
Problem is this results in the following error:
Uncaught Error: 01/06/12 14:43 PM is not a supported date/time string
jquery.localtime-0.5.js:183
The text being passed to the plugin looks like this "2012-06-01T21:43:15Z" any ideas? Am I calling the plugin incorrectly? Thanks
Upvotes: 0
Views: 339
Reputation: 1903
The problem is that the localtime plugin automatically applies the formatting on the page load; so the formatting is applied when the page loads, and again using the code you supply above.
Either prevent the plugin from applying the style by default:
<script type="text/javascript">$.localtime.setFormat({});</script>
Or remove your code that attempts to re-apply it a second time.
Upvotes: 2