How to convert unixtimestamp to date using php function


how to convert unixtimestamp to date using php to solve this problem

echo date('Y-m-d H:i:s', $myTimestamp);




i store the multicheckbox values as a sumofarray in database, i want to compare the values with original and set as checked , how do it can any one help me to solve the problem

for example

<input type="checkbox" value="1" name="val[]">
<input type="checkbox" value="2" name="val[]">
<input type="checkbox" value="4" name="val[]">
<input type="checkbox" value="8" name="val[]">

thank u

$checkboxes = array(
  1 => false,
  2 => false,
  3 => false,
  4 => false,
  5 => false

  Values from database
$database = array(
  2 => true,
  4 => true,

foreach(array_replace($checkboxes, $database) as $value => $isChecked){
    '<input type="checkbox" name="val[]" value="%s" %s />' . PHP_EOL,
    $isChecked ? 'checked="checked"' : ''

  <input type="checkbox" name="val[]" value="1"  />
  <input type="checkbox" name="val[]" value="2" checked="checked" />
  <input type="checkbox" name="val[]" value="3"  />
  <input type="checkbox" name="val[]" value="4" checked="checked" />
  <input type="checkbox" name="val[]" value="5"  />

i m storing checkbox array values as sum in database
if first and second checkbox check i m storing the values as sum of array

array_sum(checkbox array) in database

now values from database is 2+4 =6

how to decode and set check box as checked status

See my answer in your other thread.