PHP: Date to Timestamp

I am trying to format a normal date into a timestamp. To convert a timestamp into the normal date was no problem, but now I have an array with 4 different dates! 2 normal dates : 1991-12-09, 12.03.1984 and also 2 timestamps in one array. If I had the same format I could strpos it and make an if and test with “.” that worked last time, but now I have those 4 different formats. Anyone an idea?

I think this is what you’re looking for?

[php]<?php
// 1991-20-09 is an invalid date format:

$myDates = array(‘1991-09-20’, ‘12.03.1984’, ‘August 28, 1964’);

function convertDate($date) {
foreach($date as $key => $value) {
$formatDate = date(‘F j, Y’, strtotime($value));
echo 'Raw Date ’ . $value . ’ Formatted Date ’ . $formatDate . “
\n”;
}
}

convertDate($myDates);[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service