php function to converts seconds into timestamp

Posted on 2011-10-04
Last Modified: 2012-06-21
i need any php function which can converts seconds into timestamp
for eg.




now i want to convert the time into complete timestamps in format 2011-10-04 22:41:15
Question by:savsoft
    LVL 10

    Accepted Solution

    Use the date function.

    date('Y-m-d H:i:s', $time);
    LVL 82

    Expert Comment

    by:Dave Baldwin
    $today = date("Y-m-d H:i:s", $time);

    It is not a good idea to name variables with the names of functions like $time=time();
    LVL 13

    Expert Comment

    by:Hugh McCurdy
    Dave makes an excellent point about variable naming.  For a timestamp of the current time, I typically use $now.  Ideally the variable you use should provide information about the purpose of the variable.  $lastVisitTime, $accountCreated, $lastPurchaseTime, $bookDueDate.
    LVL 107

    Expert Comment

    by:Ray Paseur
    Seconds ARE timestamps!

    Something in format 2011-10-04 22:41:15  is not a timestamp.  It is an ISO-8601 DATETIME string.  Please take a moment to read over this article.  I think you will find it helpful.

    Best regards, ~Ray

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    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…
    Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
    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 count occurrences of each item in an array.

    728 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