Php Date or Time

Simplest display of date or time is telling your users what time it is.
Use the date( ) or strftime( )

strftime( ) says: Wed Oct 20 12:00:00 2004

date( ) says: Wed, 20 Oct 2004 12:00:00 -0400

Both strftime( ) and date( ) take two arguments.
The first controls how the time or date string is formatted,
and the second controls what time or date to use. 

print date('m/d/y');




The date( ) and strftime( ) functions each have their strong points.
 If you are generating a formatted time or date string that has
other text in it too, strftime( ) is better because you don't have to
worry about letters without percent signs turning into time or date values.


print 'strftime( ) says: ';
print strftime('Today is %m/%d/%y and the time is %I:%M:%S');
print "\n";
print 'date( ) says: ';
print 'Today is ' . date('m/d/y') . ' and the time is ' . date('h:i:s');



The date( ) function shines for different reasons. It supports
some things that strftime( ) doesn't, such as a leap year indicator,
 a DST indicator, and trimming leading zeroes from some values.
 Furthermore, date( ) is a PHP-specific function. The strftime( ) PHP
 function relies on an underlying operating system function also
called strftime( ). That's why some format characters aren't supported
on Windows. When you use date( ), it's guaranteed to work the same
 everywhere. Unless you need to put text that isn't format characters
 into the format string, choose date( ) over strftime( ).




Related Posts:
  • PHP's variable-related functions PHP's variable-related functions are a key part of the language. Skilled programmers rely on them extensively to build robust code that uses type-checking. Functions like var_dump() and print_r() are also invaluable w… Read More
  • mysql_query-executes query mysql_query function  executes query on the default database, set using mysql_select_db() or by a previous query using mysql_db_query(), on the MySQL server connection referenced by connection . If no connection … Read More
  • Php global variables Php Mail Php Array Php If else Php Variable This is a link Php Substrings Php Sessions Php global variables variables are automagically available in all contexts in function and global scopes. T… Read More
  • php job in kolkata Learn web design & development with sitepoint tutorials, courses and books -  html5, css3, javascript, php, mobile app development, responsive web design.  In-depth tanking class/job analysis - tutorials and … Read More
  • Database Functions-PHP MySQL PostgreSQL MS SQL (Microsoft) Chances are good that you will have at least one of these databases available to you (very good since MySQL and PostgreSQL are available for free download). There are four… Read More
  • Php-Associative Arrays Arrays are another basic structure in programming languages. Arrays provide means for storing a fixed set (or collection) of the same datatype in a convenient way, making each element of your set indexable by using a uniqu… Read More
  • PHP Tutorial PHP Functions Php tutorial - imagemagick php.ini Basics PHP Sessions Cookies Versus Sessions PHP Web-Related Variables PHP ERRORS maximum size of a file uploaded Php Image upload php file_get_conte… Read More
  • Php Form Example Since you'll need a place for the user to enter a search query, let's begin by building a form to handle the user's input. Every form must have these basic components:The submission type defined with the method keywordOne… Read More
  • php mvc tutorial for beginners-Model-View-Controller In most PHP web applications, you won’t have a strict MVC setup. In fact, it’s quite a lot of work to go full-on MVC with PHP. Getting a web project off the ground can be cumbersome and technically demanding, especially … Read More
  • Advanced Database Job PHP PHP supports the following databases in one form or another: MySQL— www.mysql.com mSQL— www.hughes.com.au MS SQL (Microsoft SQL server; on Win32 systems only) filePro (Read only)— www.fptech.com Informix— (fr… Read More
  • Sends a message via mail function in PHP mail function allows you to send email directly from a PHP script. recipient can be  either a single email address or a comma-delimited list of addresses.  If you want to set extra headers—for instance, in order … Read More
  • Abstract data type In programming, a data set defined by the programmer in terms of the information it can contain and the operations that can be performed with it. An abstract data type is more generalized than a data type constr… Read More
  • Php for-web developers   PHP MySQL Functions Free Hosting Requiring Cookies Web Application with PHP php -Mail Functions PHP Array Substrings PHP Comparison Operators for If/Else Statements Showing the Browser and I… Read More
  • PHP mail function  sendmail cofiguration in php.ini file  If the smtp server you're trying to relay the    email to requires you to authenticate mail() will fail. <?php // ---------------- SEND MAIL FORM -------------… Read More
  • Advanced PHP PHP's strength lies in its huge library of built-in functions, which allows even a novice user  to perform very complicated tasks without having to install new libraries or worry about low-level details, as is often th… Read More