Solved

Today's date and time in seconds

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
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…
The viewer will learn how to dynamically set the form action using jQuery.

919 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now