0

Created a simple time function which it returns a foreign time when user clicks on Now. Initially it didn't require session_start, but after a few test runs it started to give this error.

php

$start_time = $_GET['time'];
$city = $_GET['city'];
date_default_timezone_set(city);
echo date('Y-m-d H:i:s', strtotime($start_time));

What I understand about session_start is it is needed for session variables to work, but this situation has nothing to do with session, it is just a simple script. So I hope someone can enlighten me please? Thanks in advance

Community
  • 1
  • 1
roger
  • 1,225
  • 2
  • 17
  • 33
  • Strange. What error do you get when you dont have session_start(); – Jason Joslin May 01 '17 at 22:23
  • Is that all the code? Is it in the actual requested page or does it get included from another page? Btw, It's probably a typo, but I guess you mean to pass `$city` and not `clty` (constant) to `date_default_timezone_set()`; – M. Eriksson May 01 '17 at 22:25
  • @JasonJoslin `Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent [Domain/folder/phpfile]` – roger May 01 '17 at 22:32
  • @MagnusEriksson That is the base of actual code, others are just `echo this` and `echo that` and no `$_SESSION`. It happened once before with other php file, which I found it was queer. Most part of that script is just data query and `echo` results. – roger May 01 '17 at 22:36
  • 2
    That error sounds like you are using session_start or something that modifies the session very late in the script. without being able to see all the code i cant help sorry. hopefully someone else has had this issue before and knows what it will be straight away. – Jason Joslin May 01 '17 at 22:36

0 Answers0