This is a little script to get the weekdays and the months in danish, when website is located on server in the US. But is it possible to add +9 hours to the time so that it will be the correct european (danish)time/date.
I was thinking about adding something to the getdate() line?? Can anyone help?
Thanks
<?php
function dagsdato()
{
$weekdays = array("Søndag","Mandag","Tirsdag","Onsdag",
"Torsdag","Fredag","Lørdag");
$month = array("januar","februar","marts","april","maj",
"juni","juli","august","september","oktober",
"november","december");
$dato_array = getdate();
return $weekdays[$dato_array[wday]] . " d. ". $dato_array[mday] . ". " .$month[($dato_array[mon]-1)] . " ".$dato_array[year];
}
?>
plus 9 hours to date/time php
Started by the jil, May 05 2010 01:48 AM
3 replies to this topic
#1
Posted 05 May 2010 - 01:48 AM
|
|
|
#2
Posted 05 May 2010 - 04:39 PM
To just add 9 hours? Yea that's simple.
The date function actually accepts the time in seconds in the second non required field which shortcuts to now() if left empty. A function called "strtotime()" will output those seconds and accepts values like "+9 hours" or "-3 weeks" etc.
I'm kinda guessing on the date format... that's from memory and I don't use that function often. But you get the idea.
The date function actually accepts the time in seconds in the second non required field which shortcuts to now() if left empty. A function called "strtotime()" will output those seconds and accepts values like "+9 hours" or "-3 weeks" etc.
<?PHP
echo date('m/d/Y H:i:s', strtotime('+9 hours'));
I'm kinda guessing on the date format... that's from memory and I don't use that function often. But you get the idea.
#3
Posted 05 May 2010 - 05:18 PM
also check out the function PHP: setlocale - Manual which can be handy, also, this function can be nice: PHP: DateTime::setTimezone - Manual
I think a dane would like a date formatted this way:
BlaineSch said:
To just add 9 hours? Yea that's simple.
The date function actually accepts the time in seconds in the second non required field which shortcuts to now() if left empty. A function called "strtotime()" will output those seconds and accepts values like "+9 hours" or "-3 weeks" etc.
I'm kinda guessing on the date format... that's from memory and I don't use that function often. But you get the idea.
The date function actually accepts the time in seconds in the second non required field which shortcuts to now() if left empty. A function called "strtotime()" will output those seconds and accepts values like "+9 hours" or "-3 weeks" etc.
<?PHP
echo date('m/d/Y H:i:s', strtotime('+9 hours'));
I'm kinda guessing on the date format... that's from memory and I don't use that function often. But you get the idea.
I think a dane would like a date formatted this way:
echo date('Y-m-d H:i:s', strtotime('+9 hours'));
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall
I study Information Systems at Karlstad University when I'm not on CodeCall
#4
Posted 05 May 2010 - 11:09 PM
Thank you so much, this did the trick!
$dato_array = getdate(strtotime('+9 hours'));:thumbup1:


Sign In
Create Account

Back to top










