I have updated the PHP rpms to 5.4.3. Click here to download the rpms.
Author Archives: marc
PHP 5.4.2 for Linux Centos 6.2
I have updated the PHP rpms to 5.4.2. Click here to download the rpms.
Howto calculate Swatch internet time using PHP
date_default_timezone_set("UTC");
function internetMicrotime($get_as_float = false)
{
//Calculate Swatch internet time
//Get unix timestamp for the beginning of the this day
//With 1 hour offset for the Swatch internet timezone
//(Biel Meantime (BMT): UTC+1 without DST)
$beginningOfDay = mktime(-1, 0, 0);
//Calulate total SI seconds in a day
$totalSIsecondsInDay = 60 * 60 * 24;
//Define how many beats there are in a day
$totalBeatsInDay = 1000;
//SI seconds elapsed since the beginning of the day
$secondsElapsed = microtime(true) - $beginningOfDay;
//Calculate factor on how far this day has elapsed
$factor = $secondsElapsed / $totalSIsecondsInDay;
//Now calulate the decimal time using
//the total decimal seconds and the factor
$internetTime = $totalBeatsInDay * $factor;
if ($get_as_float)
return $internetTime;
else
return floor($internetTime);
}
print internetMicrotime(true)."\n"; //495.81894635326
print internetMicrotime(false)."\n"; //495
print date("H:i:s")."\n"; //10:53:58
Further reading: http://www.swatch.com/zz_en/internettime/
Howto calculate local hexadecimal time using PHP
date_default_timezone_set("Europe/Amsterdam");
function hexadecimalTime()
{
//Calculate hexadecimal local time
//Get unix timestamp for the beginning of this day
$beginningOfDay = mktime(0, 0, 0);
//Calculate total SI seconds in a day
$totalSIsecondsInDay = 60 * 60 * 24;
//Define how many hexadecimal seconds there are in a day
$totalHexadecimalSecondsInDay = 0xFFFF;
//SI seconds elapsed since the beginning of the day
$secondsElapsed = microtime(true) - $beginningOfDay;
//Calculate factor on how far this day has elapsed
$factor = $secondsElapsed / $totalSIsecondsInDay;
//Now calculate the hexadecimal time using
//the total hexadecimal seconds and the factor
$hexadecimalTime = $totalHexadecimalSecondsInDay * $factor;
return dechex(floor($hexadecimalTime));
}
print hexadecimalTime()."\n"; //85fc
print date("H:i:s")."\n"; //12:33:41
Howto calculate local decimal time using PHP
date_default_timezone_set("Europe/Amsterdam");
function decimalMicrotime($get_as_float = false)
{
//Calculate decimal local microtime
//Get unix timestamp for the beginning of this day
$beginningOfDay = mktime(0, 0, 0);
//Calculate total SI seconds in a day
$totalSIsecondsInDay = 60 * 60 * 24;
//Define how many decimal seconds there are in a day
$totalDecimalSecondsInDay = 100000;
//SI seconds elapsed since the beginning of the day
$secondsElapsed = microtime(true) - $beginningOfDay;
//Calculate factor on how far this day has elapsed
$factor = $secondsElapsed / $totalSIsecondsInDay;
//Now calculate the decimal time using
//the total decimal seconds and the factor
$decimalTime = $totalDecimalSecondsInDay * $factor;
if ($get_as_float)
return $decimalTime;
else
return floor($decimalTime);
}
print decimalMicrotime(true); //89580.109306784
print decimalMicrotime(false); //89580
print date("H:i:s"); //21:29:57
PHP 5.4.1 for Linux Centos 6.2
I have updated the PHP rpms to 5.4.1. Click here to download the rpms.
Updated the top 1M ipv6 list.
The list has been updated.
Out of the 990350 tested websites only 13040 have one or more IPv6 addresses. That is 1.32%.
Out of the 26089 IPv6 addresses 23493 are connectable. That is 90.05%.
UNIX Epoch 7-segment led clock.
I am busy testing a modular 7-segment led clock. Each module can contain up to 3 pieces of 7-segment led displays driven by a 74HC595D shift register. Modules can be combined into larger strings.
In the video the modules are driven by an Arduino Nano 3.0 using the SPI interface. The Arduino is connected using USB to a computer which is running a C# program that instructs the Arduino to display a certain number at a specified position. In the video the UNIX time is displayed.
The goal is to connect the display modules to a server which is connected to the GPS atomic clock and display the exact time.
Tiny DCC decoder for leds
A Tiny DCC decoder for leds has been added to the circuit section.
PHP 5.4.0 for Centos 6.2
I have updated the PHP rpms to 5.4.0. Click here to download the rpms.
Release notes: http://www.php.net/archive/2012.php#id2012-03-01-1
The key features of PHP 5.4.0 include:
- New language syntax including Traits, shortened array syntax and more
- Improved performance and reduced memory consumption
- Support for multibyte languages now available in all builds of PHP at the flip of a runtime switch
- Built-in webserver in CLI mode to simplify development workflows and testing
- Cleaner code base thanks to the removal of multiple deprecated language features
- Many more improvements and fixes
