sábado, 31 de marzo de 2018

PHP DATE practice 2

<?php

$date = new DateTime('2018/03/29 03:00');   //create  date



echo $date->format('Y-m-d H:i:sP') . "<br><br>";

$date->add(new DateInterval('P30D'));  //add 30 days to the current date


echo $date->format('Y-M-d H:i:sP') . "\n";  print date on  numeric format

echo  "<br><br>";

echo date('l jS \of F Y h:i:s A',time());  // print current date on literal

$date= $date->getTimestamp();  //  convert   a date object to time stamp

echo  "<br><br>";

echo date('l jS \of F Y h:i:s A',$date);   // print the  timestamp of the date object in  literal format


2018-03-29 03:00:00-04:00

2018-Apr-28 03:00:00-04:00

Saturday 31st of March 2018 03:11:52 PM

Saturday 28th of April 2018 03:00:00 AM

http://php.net/manual/en/function.date.php

http://php.net/manual/en/datetime.createfromformat.php

http://php.net/manual/en/datetime.formats.date.php

lunes, 26 de marzo de 2018

array line

<?php
$list=array(1,2,3,4,5,6);

$line=0;
foreach($list as $value){
$line+=1;

if($line>4){
$line=1;
}
echo "$value :$line<br>";


}

?>

1 :1
2 :2
3 :3
4 :4
5 :1
6 :2

lunes, 19 de marzo de 2018

PHP Date Practice

Creating  a date and  adding a  time interval


<?php

$date = new DateTime();



echo $date->format('Y-m-d H:i:sP') . "<br>";

$date->add(new DateInterval('P30D'));  //adding 30  days



echo $date->format('Y-m-d H:i:sP') . "\n";



Object oriented style
<?php
$date 
= new DateTime('2000-01-01');
$date->add(new DateInterval('P10D'));
echo 
$date->format('Y-m-d') . "\n";?>
Procedural style
<?php
$date 
date_create('2000-01-01');
date_add($datedate_interval_create_from_date_string('10 days'));
echo 
date_format($date'Y-m-d');?>

http://php.net/manual/en/datetime.add.php
Formats supported :http://php.net/manual/en/datetime.formats.relative.php
Creating  a  date   using computer time and also specifying time zone

<?php// Specified date/time in your computer's time zone.
$date = new DateTime('2000-01-01');

echo $date->format('Y-m-d H:i:sP') . "\n";

// Specified date/time in the specified time zone.

$date = new DateTime('2000-01-01', new DateTimeZone('Pacific/Nauru'));

echo $date->format('Y-m-d H:i:sP') . "\n";

// Current date/time in your computer's time zone.
$date = new DateTime();

echo $date->format('Y-m-d H:i:sP') . "\n";

// Current date/time in the specified time zone.
$date = new DateTime(null, new DateTimeZone('Pacific/Nauru'));
echo $date->format('Y-m-d H:i:sP') . "\n";

// Using a UNIX timestamp.  Notice the result is in the UTC time zone.
$date = new DateTime('@946684800');
echo 
$date->format('Y-m-d H:i:sP') . "\n";

domingo, 18 de marzo de 2018

printing date and unixtime

$date = date_create();  //create date object based on current date

echo date_format($date, 'Y-m-d H:i:s');  // format and print date

echo "<br>";
echo $date->getTimestamp();  // print the unix time of current date

sábado, 10 de marzo de 2018

IBM tts API

https://michaelheap.com/speech-to-text-with-ibm-watson-and-php/