Jump to content

Need help on Time Formating


neilfurry

Recommended Posts

Hi there,

 

i've been struggling on a problem converting datetime format to ISO8601

 

here is my code:

 

 

 
$string = $_REQUEST['sched-date']." ".$_REQUEST['sched-start'];
$start_string = date("Y-m-d H:i", strtotime($string));
$newformat = date('c',$start_string);

echo "String: ".$string;
echo "\n";
echo "ISO Format: ".$newformat;

 

AND Here is the output:

 

 

String: 07/30/2015 07:45 AM
ISO Format: 1969-12-31T17:33:35-07:00

 

You will notice that the ISO output is not correct. can you help me with this?

 

Thanks in advance.

 

Neil

Link to comment
https://forums.phpfreaks.com/topic/297566-need-help-on-time-formating/
Share on other sites

The second argument to date() is a number, not a string. See how the first time you used it the value came from strtotime() but the second time it came from date()?

$time = strtotime($_REQUEST['sched-date']." ".$_REQUEST['sched-start']);
$newformat = date('c', $time);

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.