Solved

Today's date and time in seconds

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

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…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

744 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

11 Experts available now in Live!

Get 1:1 Help Now