Add to Favorites    Make Home Page 29522 Online  
 Language Categories  
 Our Services  

PHP » Tips and Tutorials » Date and Time » Function to convert datetime


Search Projects & Source Codes:

Title Function to convert datetime
Platform n/a
Author Visit Author Website
Website Visit Website of - Function to convert datetime
Category PHP » Tips and Tutorials » Date and Time
Hits 633
Description With this function, you can convert a mysql datetime datatype into any other format. This way, you only need to declare the function once and be able to format your dates everywhere in your document.


Google Groups Subscribe to SourceCodesWorld - Techies Talk

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

Scripts Related to - Function to convert datetime

Script Name

Actual Time

/* The Purpose of this function is to display the actual time in your time zone if your web host has a different time from you. In the function, the variable $timediff is the time difference in seconds between your actual location and the location of your server or webhost. If you are ahead of your server type in a positive integer such as 7200. If you behind your server please enter a negative integer such as -7200. In the first example you are 2 hours ahead of your server. In the second example your are 2 hours behind your server. Our Goal is to return a time like Saturday, August 15, 2004 08:55:05 PM EST. */ function actualtime () { $timediff = -7200 ; // The time difference between your server and your time. $timestamp = date('U'); // The timestamp at your server. $timestamp = $timestamp + $timediff; // The calculated timestamp at your actual location. $weekday = date('l', $timestamp); // Day of the week like Saturday. $month = date('F', $timestamp); // Month of the year Like August. $day = date('d', $timestamp); // Day of the month like 14 $year = date('Y', $timestamp); // A full numeric representation of a year, 4 digits like 2004 $hour = date('h', $timestamp); // The time in hours. $minute = date('i', $timestamp); // The time in minutes. $seconds = date('s', $timestamp); // The time in seconds. $am_pm = date('A', $timestamp); // The Uppercase Ante meridiem and Post meridiem AM or PM. $suffix = 'Eastern Time' ; // The suffix that you would like to attach at the end of your date and time. $actualtimeis = "{$weekday}, {$month} {$day}, {$year} {$hour}:{$minute}:{$seconds} {$am_pm} {$suffix}" ; return $actualtimeis ; // function ends here. } echo actualtime (); // Prints something like Saturday, August 14, 2004 12:59:47 PM Eastern Time. >

Days Between Now And Future Date

This will calculate and show how many days there are from the current date to a date in the future that you define.

Calculating date differences

Given two dates, you can use this function to calculate the difference between them in terms of the number of years, months, weeks, hours, minutes and seconds.

Title Bar Date Script

A code snippet that displays today's date in the title bar of your web page.

Displaying the Current Date and Time

Displaying the Current Date and Time. All data which may be obtained with command Date() is shown. A couple of examples are included: link of the day and local time

Working with dates and times in PHP

In this tutorial, you will be introduced to dealing with dates in PHP.

Page generation time

This technique is very helpful when you try to optimize your PHP script. Just add a few lines of PHP code and you will get a report showing execution time of your script in milliseconds.

Educadito v.php

PHP function to greet the user, according to the hour. Written in Spanish.

Calendar of Events Listing

This tutorial describes how to write a simple script which looks at a list of events and only displays the events that occur today or in the future.

Last Modified - Tutorial and Script

This is an example rich tutorial on adding a "last modified" date and time to your website. It includes full source code and description of its use.

Google Search


Source Codes is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions
Copyright ©2003-2019, All Rights Reserved.
Page URL:

Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review