Re: display users local time

From: Date: Tue, 15 Aug 2000 06:33:16 +0000
Subject: Re: display users local time
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-11747@lists.php.net to get a copy of this message
Why not just do this with JavaScript? Here is a script which displays what you are after: <SCRIPT language=JavaScript> <!-- Begin var day=""; var month=""; var ampm=""; var ampmhour=""; var myweekday=""; var year=""; var oneDate = new Date() mydate = new Date(); myday = mydate.getDay(); mymonth = mydate.getMonth(); myweekday= mydate.getDate(); weekday= myweekday; myyear= mydate.getFullYear(); year = myyear; myhours = mydate.getHours(); ampmhour = (myhours > 12) ? myhours - 12 : myhours; ampm = (myhours >= 12) ? ' PM' : ' AM'; mytime = mydate.getMinutes(); myminutes = ((mytime < 10) ? ':0' : ':') + mytime; if(myday == 0) day = " Sunday, "; else if(myday == 1) day = " Monday, "; else if(myday == 2) day = " Tuesday, "; else if(myday == 3) day = " Wednesday, "; else if(myday == 4) day = " Thursday, "; else if(myday == 5) day = " Friday, "; else if(myday == 6) day = " Saturday, "; if(mymonth == 0) { month = "January ";} else if(mymonth ==1) month = "February "; else if(mymonth ==2) month = "March "; else if(mymonth ==3) month = "April "; else if(mymonth ==4) month = "May "; else if(mymonth ==5) month = "June "; else if(mymonth ==6) month = "July "; else if(mymonth ==7) month = "August "; else if(mymonth ==8) month = "September "; else if(mymonth ==9) month = "October "; else if(mymonth ==10) month = "November "; else if(mymonth ==11) month = "December "; // End --> </SCRIPT> </HEAD> <BODY> <SCRIPT> <!--// document.write(day + month); document.write(myweekday + ", " + year);<!---------------------- THIS LINE CHANGES -----> // --> </SCRIPT> </BODY></HTML> Hope this helps you out. Ade inovica.com ----- Original Message ----- From: <scottrus@ipass.net> To: php general <php-general@lists.php.net> Sent: Monday, August 14, 2000 4:58 PM Subject: [PHP] display users local time > Greets all - > > I seem to be missing something obvious. I want to display the date/time according to the users local > settings. Best as I can see I need to know two vars to do this, the local users LANG and the TZ they are > in. > > Does the browser pass this info in the header somewhere were php can read it? I don't want to hard code > in to display the time / date in any one region. > > Once I know the LANG and the TZ I know I can use the setlocale(), strftime(), and other date / time > functions to manuplate the date / time in to what I want. I'm just missing where to get the users local > settings from... > > Thanks for any help. > > -- > Scott > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#11747) next »