Could anyone pls convert this unixtime stamp in php? - php

I am struggling with this unixtimestamp and just cant find a correct format
Here is the stamp:
1295058844
And here is the result i want to achive:
01/14/2011 at 21:34 EST
And here is my almost correct but no luck code:
$start_unixtime = '1295058844';
date('m/d/Y \a\t H:i', intval($start_unixtime));
Basically i want EST time format, hope someone could help and sorry for such stupid question.
Thank you.

You need to use the date_default_timezone_set function before you call date.
date_default_timezone_set("America/New_York");
List of possible choices.
http://us2.php.net/manual/en/timezones.php

No need for intval.
date_default_timezone_set("TIMEZONENAME");
$start_unixtime = '1295058844';
echo date('m/d/Y \a\t H:i', $start_unixtime);

Maybe to get your "at" into there: date('m/d/Y',$x).' at '.date('H:i',$x)
After that I never could remember the codes, I tend to look them up every time.

Related

Convert date time to timestamp using php

I am quite sure this has been discussed before but for some reason mine is not working.
I am trying to convert date time to a timestamp.
echo strtotime("18 May 2.50pm");
The above code returns blank.
Any help is highly appreciated. Thanks in advance.
Use php DateTime::createFromFormat to make DateTime
<?php
$date = DateTime::createFromFormat('j M h.ia', '18 May 2.50pm');
echo $date->getTimestamp();
//print_r($date);
?>
Live Demo
Now you can use method available for DateTime .
Note : As you have not given year it will give you result for current year

PHP: how convert this time string?

i would convert this time (strftime?)
2013-07-12T07:59:27+0000
in a more simple to read "12/07/2013" (dd-mm-aaaa) and with +2 (i'm in Italy, so this time must be 09:59, no importance for seconds).
Thank you very much!
PS Could you tell me what "kinda of time expression" is, so next time i'll be more capable to search in Google without ask? :)
Try this:
echo date('d/m/Y H:i', strtotime('2013-07-12T07:59:27+0000'));
For more, read this: http://php.net/manual/en/function.strtotime.php

PHP unix timestamp to UTC zend framework

Ok, this may be a simple question, maybe I am thinking about this all wrong. Who knows.
Anyway, I am using Zend Framework and I am attempting to use cookies for the first time in it. So from my understanding cookies in Zend use a format like:
Wednesday, 28-Feb-05 20:41:22 UTC
for the expires. So I am trying to figure out how to take time() and convert it to a similar date() variation of the above that is 2 hours in the future and UTC. But like I said I think I am over thinking it, so I need confirmation.
My thoughts is
$cookie_expire = time()+7200;
$cookie_expire = date('l, d-M-y H:i:s Z', $cookie_expire);
And I wanna say this is correct, however something in my head doesn't sit well with the notion so, hopefully someone can tell me if I am off on the idea or not.
http://php.net/manual/en/function.gmdate.php
See the comment by Glen # 4-Dec-2007 04:32:
This routine can help obtain a UTC timestamp:
<?php
$utc_str = gmdate("M d Y H:i:s", time());
$utc = strtotime($utc_str);
?>
Replace the time() with the timestamp you want to convert.

Date_format() ? Question help

If I have a MySQL table field of my one date with this format (09-13-2011 11:22:43), as I do for PHP to print with this format (09/13/2011 11:22:43) Sorry my ignorance I searched the php.net site but can not find something about my request, Apologies.
$mysql_date = '09-13-2011 11:22:43';
$date = DateTime::createFromFormat('m-d-Y H:i:s', $mysql_date);
echo $date->format('m/d/Y H:i:s');
Use:
date( "m/d/Y h:i:s", UNIX_TIMESTAMP($fieldname));
If your field is already timestamp use the following:
date( "m/d/Y h:i:s", $fieldname);
I may be wrong in saying this but I don't think theres a standard way in doing so, unless you want to save the date/time as a unix_timestamp. If you do then you can format the time in however you want using the php date() function. If you aren't then you can always use something like str_replace() on the times to get them to the format you want or even use regex if your feeling adventurous
MySQL's DATE columns format is fairly irrelevant. Just use DATE_FORMAT() to convert the date to a string that suits your needs.

Date to day conversion in php

in my webpage i need to calculate the day[ie. SUN,MON,TUE...] from the date .. The date is in ['06/22/2009'] this format ? How can i calculate it in to day[That is it will show me MON] in php . Please help me to find out . Thanks in advance..
First, you need to parse the string '06/22/2009' into a timestamp, possibly using strtotime():
$dt = strtotime('06/22/2009');
Then, you can format the timestamp using date():
$day = date("D", $dt);
If you especially want it in uppercase, use strtoupper():
print strtoupper($day);
For future viewers, I think this will be more helpful.
echo date('l', strtotime('11/20/2017'));
Use the date
http://au.php.net/manual/en/function.date.php
and strtotime http://au.php.net/strtotime
functions
pls check the funcion. the out put is showing the current day.pls tell me the given date dau in the date("D",$dat)

Categories