[solved]experimenting with functions and arrays

  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

hey, i got my unix_timestamp time and date working (all thanks to scorpius aka scorpiux :shock: )

PHP Code: [ Select ]
<?PHP
 
$db_username = "";
 
$db_password = "";
 
$db_hostname = "localhost";    
 
$db_connect = mysql_connect($db_hostname, $db_username, $db_password)or die("Unable to connect to MySQL");
 
$db_select = mysql_select_db("gmforum", $db_connect)or die("Unable to select test");
 
 
 
$result=mysql_query("SELECT lastvisit FROM gs_admin");
 
$row = mysql_fetch_assoc($result);
 
 
 
 
 
 
 
//variable and for conversion
 
$lastvisited = date("m-d-y h:i:sa", $row['lastvisit']);
 
//echoed
 
echo $lastvisited;
 
 
 
?>
  1. <?PHP
  2.  
  3. $db_username = "";
  4.  
  5. $db_password = "";
  6.  
  7. $db_hostname = "localhost";    
  8.  
  9. $db_connect = mysql_connect($db_hostname, $db_username, $db_password)or die("Unable to connect to MySQL");
  10.  
  11. $db_select = mysql_select_db("gmforum", $db_connect)or die("Unable to select test");
  12.  
  13.  
  14.  
  15. $result=mysql_query("SELECT lastvisit FROM gs_admin");
  16.  
  17. $row = mysql_fetch_assoc($result);
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25. //variable and for conversion
  26.  
  27. $lastvisited = date("m-d-y h:i:sa", $row['lastvisit']);
  28.  
  29. //echoed
  30.  
  31. echo $lastvisited;
  32.  
  33.  
  34.  
  35. ?>



ok here it is, time and everything set out, now i want to add something to change the timezone, not with numbers but with functions like $timezone

ie)


PHP Code: [ Select ]
 
 
 
$timezone = array (
 
'GMT' => '+18000';
 
);
  1.  
  2.  
  3.  
  4. $timezone = array (
  5.  
  6. 'GMT' => '+18000';
  7.  
  8. );


Now if i add this:

PHP Code: [ Select ]
<?PHP
 
$db_username = "gmforum";
 
$db_password = "bae4b25u";
 
$db_hostname = "localhost";    
 
$db_connect = mysql_connect($db_hostname, $db_username, $db_password)or die("Unable to connect to MySQL");
 
$db_select = mysql_select_db("gmforum", $db_connect)or die("Unable to select test");
 
 
 
$result=mysql_query("SELECT lastvisit FROM gs_admin");
 
$row = mysql_fetch_assoc($result);
 
 
 
 
 
 
 
//timezones
 
$timezone = array (
 
'GMT' => '+18000';
 
);
 
 
 
 
 
 
 
//variable and for conversion
 
$lastvisited = date("m-d-y h:i:sa", $row['lastvisit']);
 
//echoed
 
echo $lastvisited;
 
 
 
?>
  1. <?PHP
  2.  
  3. $db_username = "gmforum";
  4.  
  5. $db_password = "bae4b25u";
  6.  
  7. $db_hostname = "localhost";    
  8.  
  9. $db_connect = mysql_connect($db_hostname, $db_username, $db_password)or die("Unable to connect to MySQL");
  10.  
  11. $db_select = mysql_select_db("gmforum", $db_connect)or die("Unable to select test");
  12.  
  13.  
  14.  
  15. $result=mysql_query("SELECT lastvisit FROM gs_admin");
  16.  
  17. $row = mysql_fetch_assoc($result);
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25. //timezones
  26.  
  27. $timezone = array (
  28.  
  29. 'GMT' => '+18000';
  30.  
  31. );
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39. //variable and for conversion
  40.  
  41. $lastvisited = date("m-d-y h:i:sa", $row['lastvisit']);
  42.  
  43. //echoed
  44.  
  45. echo $lastvisited;
  46.  
  47.  
  48.  
  49. ?>


i will then also need to do this:

PHP Code: [ Select ]
$lastvisited = date("m-d-y h:i:sa", $row['lastvisit']$timezone['GMT']);


However, i cant do this can i?

so...

$timezone = $timezone['GMT']

then i add $timezone?!?


Still no luck, i dont know how im going to add these 2 kind of arrays and functions together.

by the way, am i right in calling $name functions?!
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

ok i fixed it,

PHP Code: [ Select ]
<?PHP
 
$db_username = "";
 
$db_password = "";
 
$db_hostname = "localhost";    
 
$db_connect = mysql_connect($db_hostname, $db_username, $db_password)or die("Unable to connect to MySQL");
 
$db_select = mysql_select_db("gmforum", $db_connect)or die("Unable to select test");
 
 
 
$result=mysql_query("SELECT lastvisit FROM time_test");
 
$row = mysql_fetch_assoc($result);
 
 
 
//timezones
 
$timezone = array (
 
'GMT' => '+18000'
 
);
 
 
 
echo $timezone['GMT'];
 
 
 
//variable and for conversion
 
$lastvisited = date("m-d-y h:i:sa", $row['lastvisit']);
 
echo "<br>";
 
 
 
//echoed
 
echo $lastvisited;
 
 
 
?>
  1. <?PHP
  2.  
  3. $db_username = "";
  4.  
  5. $db_password = "";
  6.  
  7. $db_hostname = "localhost";    
  8.  
  9. $db_connect = mysql_connect($db_hostname, $db_username, $db_password)or die("Unable to connect to MySQL");
  10.  
  11. $db_select = mysql_select_db("gmforum", $db_connect)or die("Unable to select test");
  12.  
  13.  
  14.  
  15. $result=mysql_query("SELECT lastvisit FROM time_test");
  16.  
  17. $row = mysql_fetch_assoc($result);
  18.  
  19.  
  20.  
  21. //timezones
  22.  
  23. $timezone = array (
  24.  
  25. 'GMT' => '+18000'
  26.  
  27. );
  28.  
  29.  
  30.  
  31. echo $timezone['GMT'];
  32.  
  33.  
  34.  
  35. //variable and for conversion
  36.  
  37. $lastvisited = date("m-d-y h:i:sa", $row['lastvisit']);
  38.  
  39. echo "<br>";
  40.  
  41.  
  42.  
  43. //echoed
  44.  
  45. echo $lastvisited;
  46.  
  47.  
  48.  
  49. ?>


but how would i combine: $timezone['GMT'] to be added on to $row['lastvisit'] so that the time is few hours forward.
  • Nem
  • Guru
  • Guru
  • Nem
  • Posts: 1243
  • Loc: UK

Post 3+ Months Ago

at the moment it shows:

Quote:
+18000
07-18-04 04:34:44pm

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 62 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.