Solved

Today's date and time in seconds

Posted on 2007-04-01
3
240 Views
Last Modified: 2013-12-12
Experts,

I need to create today's date and time in seconds for a unique invoice reference.
0
Comment
Question by:mhouldridge
3 Comments
 
LVL 2

Expert Comment

by:wakemup
ID: 18831609
PHP's time() wil give you a unix timestamp which is seconds since 1st January 1970.

You'll only have a 1 second resolution though so if you're getting more than one request per second you'll need to use microtime() or some such depending upon your platform.
0
 
LVL 20

Expert Comment

by:steelseth12
ID: 18831613
0
 
LVL 14

Accepted Solution

by:
raja_ind82 earned 500 total points
ID: 18840136
<?php
$today  = mktime(date("g"), date("i"), date("s"), date("m")  , date("d"), date("Y"));
$tomorrow  = mktime(0, 0, 0, date("m"), date("d")+1,   date("Y"));
$lastmonth = mktime(0, 0, 0, date("m")-1, date("d"),   date("Y"));
$nextyear  = mktime(0, 0, 0, date("m"),   date("d"),   date("Y")+1);

echo $today." -Today <br>";
echo $tomorrow." -Tommorrow <br>";
echo $lastmonth." -Last Month<br>";
echo $nextyear." -Next Year<br>";
?>

Regards,
M.Raja
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question