leke Posted January 16, 2012 Share Posted January 16, 2012 I don't get why this fails. date() is meant to be a string, so why does it not concatenate correctly? date_default_timezone_set('UTC'); $inputTime = date('c'); $inputTime = $inputTime . ' (UTC)'; // or $inputTime = date('c') . ' (UTC)'; Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/255165-having-trouble-concatenating/ Share on other sites More sharing options...
Maq Posted January 16, 2012 Share Posted January 16, 2012 What's the error, or how is it failing? Quote Link to comment https://forums.phpfreaks.com/topic/255165-having-trouble-concatenating/#findComment-1308338 Share on other sites More sharing options...
scootstah Posted January 16, 2012 Share Posted January 16, 2012 It outputs 2012-01-16T21:17:55+00:00 (UTC) What's the problem? Quote Link to comment https://forums.phpfreaks.com/topic/255165-having-trouble-concatenating/#findComment-1308346 Share on other sites More sharing options...
leke Posted January 16, 2012 Author Share Posted January 16, 2012 No error returned, but the date returned is just January 01st 1970 - 12:00am (without UTC). If I remove the . ' UTC', the correct date is shown. Here is some more code that is related to the date... // Format the time/Date date_default_timezone_set('UTC'); $inputTime = date('c'); $inputTime = $inputTime . ' (UTC)'; // Send all data so far, to an array. $entry_array = array(); array_push($entry_array, $inputTime, $userName, $message_br); // write the array to CSV file. $fp = fopen('messages.txt', 'a'); fputcsv($fp, $entry_array, "|"); fclose($fp); session_destroy(); Quote Link to comment https://forums.phpfreaks.com/topic/255165-having-trouble-concatenating/#findComment-1308353 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.