howard-moore
07-14-2010, 06:13 PM
Hi All,
I wonder if you can help me with some time and date formatting in JS.
I already use a neat date formatting JS script which is useful when a PERL script returns a date field of 'DATE' by converting it from yyyy-mm-dd to dd month(in text) yyyy:
<script type = "text/javascript">
var months = ["January","February","March","April","May","June","July","August","September","October","November","December"];
var myString = "[[date]]";
var mySplitResult = myString.split("-");
var mm = parseInt(mySplitResult[1],10)-1; // note that months are 0-11
document.write(mySplitResult[2] + " " + months[mm] + " " + mySplitResult[0] );
</script>
I have, however, run across a little problem where I have results coming through with date AND time, e.g.
18:12 2010-07-14
What I need is something that will reorder the above to:
14 July 2010 at 18:12
Can someone help please!
Regards,
Neil
I wonder if you can help me with some time and date formatting in JS.
I already use a neat date formatting JS script which is useful when a PERL script returns a date field of 'DATE' by converting it from yyyy-mm-dd to dd month(in text) yyyy:
<script type = "text/javascript">
var months = ["January","February","March","April","May","June","July","August","September","October","November","December"];
var myString = "[[date]]";
var mySplitResult = myString.split("-");
var mm = parseInt(mySplitResult[1],10)-1; // note that months are 0-11
document.write(mySplitResult[2] + " " + months[mm] + " " + mySplitResult[0] );
</script>
I have, however, run across a little problem where I have results coming through with date AND time, e.g.
18:12 2010-07-14
What I need is something that will reorder the above to:
14 July 2010 at 18:12
Can someone help please!
Regards,
Neil