problem in work with dates in the following format

Total Post:29

Points:203

PHP 
PHP
 2013  View(s)
Ratings:
Rate this:
work with dates in the following format: "Tuesday, February 14, 2006 @ 10:39 am", how can we convert them to another format, that is easier to use? please give the example
  1. Re: problem in work with dates in the following format

    The strtotime function can convert a string to a timestamp. A timestamp can be converted to date format. So it is best to store the dates as timestamp in the database, and just output them in the format you like.

    So let's say we have
    $date = "Tuesday, February 14, 2006 @ 10:39 am";
    In order to convert that to a timestamp, we need to get rid of the "@" sign, and we can use the remaining string as a parameter for the strtotime function.

    for example

    $date = "Tuesday, February 14, 2006 @ 10:39 am";
    $date = str_replace("@ ","",$date);
    $date = strtotime($date);

    now $date is a timestamp
    and we can say:

    echo date("d M Y",$date);

    hi, rajesh check this sample

      Modified On Mar-29-2018 02:45:13 AM

Answer

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.