Jump to content

Recommended Posts

Try this

<?
function convertSerialDate($date)	{
	$timestamp = ($date - 25569) * 86400;
	return date("d/m/Y",$timestamp);
}

print convertSerialDate(733535);
?>

 

Fantastic

 

I have been searching the internet all morning for an answer to this one

Thank you very much

Reversing neil.johnson's function, you get:

 

<?php
function date2serial($date) {
//convert dd/mm/yyyy format to yyyy-mm-dd format
$date_arr = explode('/', $date);
$std_date = implode(array_reverse($date_arr), '-');
$timestamp = strtotime($std_date);
return round(($timestamp + 25569 * 86400) / 86400);
}
?>

 

Edit: But I'm not sure if round() gives us the desired serial for every date.

Edit 2: And some quick calculation leaves us with the simpler

 

return round(($timestamp / 86400) + 25569);

 

instead of the current return line :)

Reversing neil.johnson's function, you get:

 

<?php
function date2serial($date) {
//convert dd/mm/yyyy format to yyyy-mm-dd format
$date_arr = explode('/', $date);
$std_date = implode(array_reverse($date_arr), '-');
$timestamp = strtotime($std_date);
return round(($timestamp + 25569 * 86400) / 86400);
}
?>

 

Edit: But I'm not sure if round() gives us the desired serial for every date.

 

Thank you so much

 

This has made me very very happy

I have run a test and it converted the data back to a serial date successfully

 

I will add it to my script and let you know if I encounter any problems

 

Thank you

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.