Solved

Today's date and time in seconds

Posted on 2007-04-01
3
246 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.

829 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