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.

 

 

 

 

Link to comment
Share on other sites

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 ;)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.