Jump to content

[SOLVED] apply mktime to an array of time/dates


gspica

Recommended Posts

I have an array of time/dates  - $timedate[]

 

I need to apply mktime to each time\date in the array

 

$timedate[0] = 00,00,00,05,20,2003

 

$timedate[20] = 00,00,00,11,03,2004

 

When I attempt to run mktime against $timedate[0] and $timedate[20] I get the same result

 

mktime($timedate[0]) = 1184831045

 

mktime($timedate[20]) = 1184831045

 

if I run

 

mktime(00,00,00,05,20,2003) = 1053414000

 

mktime(00,00,00,11,03,2004) = 1099465200

 

Why is this? And how can I convert these to mktime. I am pulling the dates from a mysql database.

 

 

 

 

Why are you using mkdir()?

 

<?php

$originals = array("00,00,00,05,20,2003", "00,00,00,11,03,2004");
$timestamps = array();

foreach($originals as $k => $v) {
$pieces = explode(",", $v);
$timestamps[$k] = mktime($pieces[0], $pieces[1], $pieces[2], $pieces[3], $pieces[4], $pieces[5]);
}

// $timestamps[0] = 1053414000
// $timestamps[1] = 1099465200

?>

 

Maintains original array keys in the output array ;)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.