<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — javascript date formatter]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=3051&amp;type=atom" />
	<updated>2012-05-09T04:44:51Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=3051</id>
		<entry>
			<title type="html"><![CDATA[javascript date formatter]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=12423#p12423" />
			<content type="html"><![CDATA[<p>Hi Guys<br />I have a date formatter piece of javascript that turns a date eg 011211 into 01/12/2011.<br />I&#039;m just wondering where I would add this to the code to activate it for things like OrderDate in Direct Invoice.?<br />Thanks<br />Pete</p><div class="codebox"><pre><code>function addSlashes(input) {
    var v = input.value;
    var startYear = &#039;&#039;;
    // If it&#039;s only 2 digits and 2 digits long, add one slash
    if (v.match(/^\d{2}$/) !== null) {
        input.value = v + &#039;/&#039;;
        // If up to year, add slash again.
    } else if (v.match(/^\d{2}\/\d{2}$/) !== null) {
        input.value = v + &#039;/&#039;;
    }
    // If six chars, add year
    
    if (v.match(/^\d{2}\/\d{2}\/\d{2}$/)) {
        
        // 24/12/08 
// substring from - to (to is char position so always &gt; from)

        if (v.substring(6,8)&gt;30) {
            startYear = &#039;19&#039;;
        }
        else {
            startYear = &#039;20&#039;;
        }
        input.value = input.value.substring(0,6)  + startYear + input.value.substring(6,8);
    }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[p2409]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=267</uri>
			</author>
			<updated>2012-05-09T04:44:51Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=12423#p12423</id>
		</entry>
</feed>
