Someone
Someone

Reputation: 10575

How to change the Date format that we get from text field "16-JUL-2010" to 20100716 using php or using jquery

How to change the Date format that we get from text field "16-JUL-2010" to 20100716 using php or using jquery

Upvotes: 0

Views: 199

Answers (3)

Adam
Adam

Reputation: 44949

In javascript you'd be best off using the Date.js library

<script type="text/javascript" src="http://www.datejs.com/build/date.js"></script>
<script type="text/javascript">
    d = Date.parse("16-JUL-2010")
    d.toString('yyyyMMdd');
</script>

Upvotes: 0

Daniel Egeberg
Daniel Egeberg

Reputation: 8382

$date = DateTime::createFromFormat('d-M-y', $_GET['date']);
echo $date->format('Ymd');

Upvotes: 1

Wrikken
Wrikken

Reputation: 70500

echo date('Ymd',strtotime("16-JUL-2010"));

Upvotes: 1

Related Questions