Jump to content

Current Time


johnbruce

Recommended Posts

Hi all,

 

I currently have the following code that writes values back to a mysql database, as you can see the last 2 fields are date and time. The date field works fine and writes the current date back to the db, how do I write the current time back to the last field?

 

$date = date("Y-m-d ");
$query = "INSERT INTO applicants VALUES ('','$title','$first','$last','$phone','$mobile','$site','$email','$avaliable','$experience','$date','time()')";

 

Regards,

John

Link to comment
Share on other sites

hmm.. i'm not sure, but it might be that since the php is server-side scripting it returns the current time on the server... but i belive, correct me if I'm way off here, that JavaScript will get the current time from the users computer

Link to comment
Share on other sites

here... just activate this function... it'll change your servers default timezone :-)

<?php
function set_timezone($timezone="0"){
switch($timezone){
  case "-12": date_default_timezone_set('Etc/GMT+12'); break;
  case "-11": date_default_timezone_set('Etc/GMT+11'); break;
  case "-10": date_default_timezone_set('Etc/GMT+10'); break;
  case "-9": date_default_timezone_set('Etc/GMT+9'); break;
  case "-8": date_default_timezone_set('Etc/GMT+8'); break;
  case "-7": date_default_timezone_set('Etc/GMT+7'); break;
  case "-6": date_default_timezone_set('Etc/GMT+6'); break;
  case "-6": date_default_timezone_set('Etc/GMT+5'); break;
  case "-4": date_default_timezone_set('Etc/GMT+4'); break;
  case "-3": date_default_timezone_set('Etc/GMT+3'); break;
  case "-2": date_default_timezone_set('Etc/GMT+2'); break;
  case "-1": date_default_timezone_set('Etc/GMT+1'); break;
  case "0": date_default_timezone_set('GMT'); break;
  case "1": date_default_timezone_set('Etc/GMT-1'); break;
  case "2": date_default_timezone_set('Etc/GMT-2'); break;
  case "3": date_default_timezone_set('Etc/GMT-3'); break;
  case "4": date_default_timezone_set('Etc/GMT-4'); break;
  case "5": date_default_timezone_set('Etc/GMT-5'); break;
  case "6": date_default_timezone_set('Etc/GMT-6'); break;
  case "7": date_default_timezone_set('Etc/GMT-7'); break;
  case "8": date_default_timezone_set('Etc/GMT-8'); break;
  case "9": date_default_timezone_set('Etc/GMT-9'); break;
  case "10": date_default_timezone_set('Etc/GMT-10'); break;
  case "11": date_default_timezone_set('Etc/GMT-11'); break;
  case "12": date_default_timezone_set('Etc/GMT-12'); break;
}
}
set_timezone('-5');
?>

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.