Monday, February 27, 2012

Calculates the age in php

This simple function calculates the age, in years, of a date supplied in any format supported by the strtotime() funcition, which means, basically, any date you can sanely imagine.

Code of function is:

Twenty Four Hour to Twelve Hour

Recently I have created robotic mailing system for my client. But when it needed to convert a bunch of 24 hour times to 12 hours, the times were in different formats but I needed them in a format that was easily human readable. This function will convert a twenty four hour time to twelve hour time. Feel free to modify it to your own needs.

Code is here:

Convert Unix Timestamp To MySQL Timestamp

PHP date functions such as strtotime() and time() and date() all return a value as a UNIX TIMESTAMP. This is great for date manipulation but becomes a problem when we need a date to INSERT into a MySQL database. The format of a MySQL TIMESTAMP is yyyy-mm-dd hh:mm:ss and to meet this need a simple PHP can be utilized to convert any UNIX TIMESTAMP into a MySQL TIMESTAMP.

Code and use of function is:

Thursday, February 9, 2012

Image converter class in php

Image converter is so important to a designer and developer. When you want to upload images in host you should convert it in a desired file system. I have create a class in php to convert image to all kind of image from source file system. By this you can create a online image converter. If you create online image converter using this code or develop this please mail me.

It is so easy to call as the code:
[php]

<?php
require("class.imageconverter.php");

$img = new ImageConverter("2000.gif","wbmp");

?>

[/php]
All of code is here:

Thursday, February 2, 2012

Using PHP/MySQL with Google Maps API

Google map api
Process for using google map api in php:
-> Create a table in database.
-> A file to create a dynamic xml creator code in php
-> Index file to load and display the map including location indicator

Create table in database:
[php]
CREATE TABLE `markers` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` VARCHAR( 60 ) NOT NULL ,
`address` VARCHAR( 80 ) NOT NULL ,
`lat` FLOAT( 10, 6 ) NOT NULL ,
`lng` FLOAT( 10, 6 ) NOT NULL ,
`type` VARCHAR( 30 ) NOT NULL
) ENGINE = MYISAM ;
[/php]

Insert the values of attributes in databases table.
as by code:
[php]
INSERT INTO `markers` (`name`, `address`, `lat`, `lng`, `type`) VALUES ('Mr.Insafeta', 'Mohammadpor, Dhaka, Bangladesh', '47.608941', '-122.340145', 'Home');
[/php]

Create database connect page in php (dbinfo.php):