viernes, 25 de agosto de 2017

print date utc and convert date to time stamp

<?php
print gmdate("Y-m-d\TH:i:s\Z");

$utc=gmdate("Y-m-d\TH:i:s\Z");
echo "<br>";

echo strtotime($utc);

echo "<br>";

$fromunixtime_utc=gmdate("Y-m-d\TH:i:s\Z",strtotime($utc));

echo $fromunixtime_utc;

?>

2017-08-26T02:52:01Z
1503715921

viernes, 18 de agosto de 2017

returning as json content type

<?PHP
$data = /** whatever you're serializing **/;
header('Content-Type: application/json');
echo json_encode($data);

https://stackoverflow.com/questions/4064444/returning-json-from-a-php-script

miércoles, 2 de agosto de 2017

php convert array to json

<?php
$myArr = array(
    "Name" => "Ambiorix",
    "Lastname" => "Rodriguez",
         "age" => 35,
         "ocupation" =>array('lawyer','IT Manager')
);
//array to json
$myJSON = json_encode($myArr);

echo $myJSON;

echo "<br>";
//json to array
print_r(json_decode($myJSON,true ));

json viewer

http://jsonviewer.stack.hu/