0

i am trying to make php timestamp function i make it like this

My code example

$t=time(); 
echo($t . "<br>"); 
echo(date("Y-m-d",$t));

but i want php timestamp in this format

Saturday, August 18, 2018 10:55:34 AM GMT+05:30

output:-1534569934

what i need to changes in my code

Peter
  • 777
  • 2
  • 13
  • 34

3 Answers3

0

Here is what i tried,

<?php
$t = time(); 
echo(date("l, M d, Y h:i:s A",$t).' GMT '.date("O",$t));

I hope this solves your problem :-)

Krishanu
  • 552
  • 3
  • 21
0

According to :

i want php timestamp in this format

Saturday, August 18, 2018 10:55:34 AM GMT+05:30

you can format your timestamp as this:

date('l ,F d,  Y h:i:s A \G\M\T P');

you also said :

i am trying to make php timestamp function

First ,i don't see any function declaration nor return statement so you didn't try to make a function.However according to the format above and the fact that you want a custom timestamp function, you can build it this way:

function custom_timestamp(){
    return date('l,F d,Y h:i:s A \G\M\T P');
}

Then you can use it anywhere as timestamp and based on your own logic.

Elementary
  • 1,443
  • 1
  • 7
  • 17
0

You can try this:

<?php
    $timestamp=time();
    echo(date("F d, Y h:i:s A", $timestamp));
?>
Grant Miller
  • 27,532
  • 16
  • 147
  • 165
PHP Geek
  • 3,949
  • 1
  • 16
  • 32