php date time supporting date values before year 1970

“I need to store birthdate of my customers where it can fall before year 1970.” Php function date(), strtotime() uses UNIX timestamp which supports year 1970 to 2038. To work with date values beyond that, we need to use php datetime class which is available on after php version 5.2.0 (datetime manual). Create a date before 1970: $dt = new DateTime(); $dt->setDate(1945, 8, 8); // August 8 1945, end of world war 2 If you need to store time as well: //public DateTime DateTime::setTime ( int $hour , int $minute [, int $second = 0 ] ) //seconds argument is optional $dt->setTime(8,0,45); // 8:00:45 am To print the date: echo¬†$dt->format('Y-m-d H:i:s'); //outputs //1945-08-08 08:00:45 For list of date format to use, refer to http://php.net/manual/en/function.date.php. Hope it helps....

Integrated Development Environment (IDE) for PHP / HTML / CSS / JavaScript

1. Aptana Studio 3 by Appcelerator, Inc Platform independent as the IDE runs on Java JRE and supported programming languages are HTML5, CSS3, JavaScript, Ruby, Rails, PHP and Python. Aptana Studio 3 is currently release under “GNU General Public License“.   2. Adobe Dreamweaver CS5.5 by Adobe Systems Favourite by large web development firms. Runs on mac osx and windows platform. Supported programming languages are HTML5, CSS3, JavaScript, PHP, ColdFusion Markup Language (CFML) , VBScript (for ASP), C# and Visual Basic (for ASP.NET) and JSP. Commercial license required to install and use.   3. Eclipse by Eclipse Foundation Open source community, whose projects are focused on building an open development platform comprised of extensible frameworks, tools and runtimes for building, deploying and managing software across the lifecycle. Platform independent as the IDE runs on Java JRE. Download the Eclipse PDT package for PHP support. Currently release under “Eclipse Public License (EPL)“.   4. Zend Studio 8 by Zend Technologies Ltd According to their FAQ, Zend Studio is a commercial IDE with rich a feature set including remote debugging, Zend Server integration, Zend Framework support, and more. Supported programming languages are HTML, CSS, JavaScript and PHP. If your presentation uses JavaScript libraries such as Dojo, jQuery, Prototype and Ext JS, then you may want to consider Zend Studio as it comes with content assist for the libraries. Zend Studio 8 runs on linux, mac osx and windows. Commercial license required for use after 30 days...

PHP XMPP Google Talk send notification message to IPhone

The example below, I am going to show you how you can send notifications using PHP XMPP library. I am using CodeIgniter 2.0, a php framework, PHP XMPP library and MySQL database in the example. The receiving end, I am using an iPhone installed with an instant messaging app, setup with Google Talk account to receive push notifications. I chose IM+ free version. It’s up to you which app you prefer but I recommend at least one with push notifications on new messages so it served as some sort of “notification”. What you need? Latest version of PHP XMPP library. 2 x Google talk account, one for receiving and one for sending the notifications. PHP enabled server. Optional – MySql database for storing of notification queues. You may choose to read the notifications queue from a file, memory pipe and etc…. PHP server settings Important! Ensure PHP OpenSSL module is enabled. I encountered infinite loop when connecting to GTalk server while OpenSSL module is disabled. Click here if you need help. Firstly, install the PHP XMPP package in “/libraries/xmpp”. Create the model which reads the notification queue for new message to send. //M_notification_queue.php file ... function getUnsendNotifications(){ //Load the database $this->load->database(); //Build the sql query //Retrieve unsent messages only $this->db->where('status','unsent'); //Retrieve from table notification $query = $this->db->get('notification'); //return the active record handler return $query; } ... Implement the sending controller //notification.php controller file private $gtalk_username = "sender@gmail.com"; //fake email private $gtalk_password = "password"; //fake password private $check_notification_interval = 10; //frequency to check for unsent message ... function sendNotificationCronJob(){ //load required models $this->load->model('M_notification'); //initialize the xmpp library $conn = new...

PHP Formatting Date

To display current date we use the date function in PHP. <?php //string date ( string $format [, int $timestamp ] ) echo date("Y-m-d H:i"); ?> Result: 2018-12-16 00:08 The date() function requires 1 parameter which is the string format to format the current date time to our liking. Refer to the php date documentation for more details on the formatting string. The 2nd optional parameter which takes in an integer value representing the date time comes in handly where in some situation, we need to display specific dates. We use mktime() function to create the specific date time. <?php //int mktime ([ int $hour = date("H") [, int $minute = date("i") [, int $second = date("s") [, int $month = date("n") [, int $day = date("j") [, int $year = date("Y") [, int $is_dst = -1 ]]]]]]] ) //mktime(8,0,0,10,20,2010) creates a date time specific to 20th October 2010, 8:00 am echo date("Y-m-d H:i",mktime(8,0,0,10,20,2010)); ?> Result: 2010-10-20...

Introduction to PHP

PHP = Hypertext Preprocessor So what is PHP? Google “what is PHP?”, you will get loads of result on the definition. Here’s some: PHP – Wikipedia, the free encyclopedia PHP Introduction In this category you will find tutorials on common PHP codes, reusable classes for use in your projects. All codes released in this section are licensed under GPL, unless otherwise specified by the original...