how does this function work? how can i adjust this to a different language then english and the time zone as well?
if possible?

i think this is the code

function formatDate($val)  
  {  
      list($date, $time) = explode(" ", $val);  
      list($year, $month, $day) = explode("-", $date);
      list($hour, $minute, $second) = explode (":", $time);
      return date("l, m.j.y @ H:ia", mktime($hour, $minute, $second, $month, $day, $year));  
  }

i read it but my php skill is very very limited almost none, would you please help me to incoropate that.
thank you

function formatDate($val)  
  {  
      list($date, $time) = explode(" ", $val);  
      list($year, $month, $day) = explode("-", $date);
      list($hour, $minute, $second) = explode (":", $time);
      return date("l, m.j.y @ H:ia", mktime($hour, $minute, $second, $month, $day, $year));

There is nothing in that script that is set to language or timezone specific.
the dateformat is described fully in the online php manual at www.php.net
This script takes a date stored in a database by some slow thinking desgner(1) as a text string, breaks it and creates a manipulatable data set and returns a date.
What should happen is the database designer & programmer be fired.
then the database modified so that the data already stored is converted to a timestamp, and all future stored dates be stored as a timestamp
then the script is redundant and becomes

echo date("l, m.j.y @ H:ia", $val));

coding for language and regional date styles is just a matter of changing the date string, which can be in user config, by button, or in the code if the change is permanent

Note 1. I think he/she(designer/programmer) is a bleep idiot.

i know it is a lot to ask but i really don't understand it. would it be possible to show me how the code would look like for a different language and time?

thank you

the time is stored in the variable $val
the time is diplayed by date("l, m.j.y @ H:ia", timestring); the contents of date(format, timestring) are explained at the php.net link already given

This is the ideal opportuinity for you to develop your limited php skills.
If you dont correct the database, then you need to alter the format string in the foriginal function date("l, m.j.y @ H:ia", mktime($hour, $minute, $second, $month, $day, $year)) l=monday
m=month-1-12
j=day
y=year as explained at the php.net link already given

I am taking this opportunity to develop my polite conversational skills

nope didn't work
read the bleep manual

it is already embrasing to ask and thank you for being polite. if i would understand the bleep manual i would not ask but thanks for the advise. i will try to work on it.

it is already embrasing to ask and thank you for being polite. if i would understand the bleep manual i would not ask but thanks for the advise. i will try to work on it.

The manual is in languages other than english, may make it easier to follow, I think in the upper left of the page,
follow the date() page down to where it demonstrates setLocale()
You will not be able to change the displayed time, that is read from the variable $val
as your skills develop, consider changing the stored text dates to a timestamp <= google unix timestamp=, its is smaller faster less overhead to use numeric only dates. might not mean much now, but plan on growth.

still practising polite conversation
still didnt work
read the bleep manual

lol
i will try and let you know how it goes

thank you

With the following code, you will get English date format like
«Tuesday February 10, 2009 - 13:08:09»

<?php
setlocale(LC_TIME, "C");
echo ucfirst(strftime("%A %B %e, %Y %t - %X"));
?>

With the following code, you will get French date format like
«Mardi le 10 février 2009 - 13:08:09»

<?php
setlocale(LC_TIME, "fr_FR");
echo ucfirst(strftime("%A le %e %B %Y %t - %X"));
?>

Remove « - %X» on third line if you don't want «h:m:s»

C = English
fr_FR = French
fi_FI = Finnish
de_DE = German
es_ES = Spanish
pt_PT' = Portuguese
etc...

Maybe someone can give us a link to the complete list... I didn't found it !

this what exacly i need, where do i add this code to?

<?php
setlocale(LC_TIME, "C");
echo ucfirst(strftime("%A %B %e, %Y %t - %X"));
?>

thank you

this what exacly i need, where do i add this code to?

<?php
setlocale(LC_TIME, "C");
echo ucfirst(strftime("%A %B %e, %Y %t - %X"));
?>

thank you

??? I don't understand your question ?
It will appear everywhere you add the code !

About Language complete list:
I believe that the language variable refer to «ISO 639-1 Code» convention...
http://www.loc.gov/standards/iso639-2/php/code_list.php

commented: thank you +1

can i add this code to where this code is

function formatDate($val)  
  {  
      list($date, $time) = explode(" ", $val);  
      list($year, $month, $day) = explode("-", $date);
      list($hour, $minute, $second) = explode (":", $time);
      return date("l, m.j.y @ H:ia", mktime($hour, $minute, $second, $month, $day, $year));

if it is do i include <?php
and this ?> where would i add the code or do i include it on my html

thank you

If you just want to include something like
«Tuesday February 10, 2009 - 15:31:11»
you don't need no more your previous function
(function formatDate...)".

I suppose you know that your page extension need to be .php (not .html).

Simply paste the code between the html tags, like...

<html>
   <head>
      <title>Your Page Title</title>
   </head>

<body>
      <p>
            <?php
               setlocale(LC_TIME, "C");
               echo ucfirst(strftime("%A %B %e, %Y %t - %X"));
            ?>
      </p>
</body>
</html>

this would work very well for me but the problem is that it does not work for all the languages, i tried german french english they all work but turkish does not work and some other languages i tested as well. any ideas?

thank you

I just tried tr_TR (Turkish) and I obtained : Salý 10 Þubat 2009 - 19:22:56

I do not speak this language but I assume it's OK...

Your page encoding (UTF-8, iso-8859-1, etc...) may affect the presentation of exotic characters.

i get this

February 10, 2009 - 20:41:40

with

<?php
setlocale(LC_TIME,"tr_TR");
echo ucfirst(strftime("%A %B %e, %Y %t - %X"));
?>

am i doing something wrong

i get this for french

Mardi f�vrier 10, 2009 - 20:46:22

Which charset (page encoding) are you using ?

original html is utf-8

what encoding are you using?

Try charset=iso-8859-1 for french usage or some other language

in case it does not work, how could i display the date
only
day-month-year

thank you

i think i miss understood
this date is displaying the current time not the time when the post was added

??

5he date variable $var is undefined, not stored
is $var your variable, or a variable in an instructional tutorial or app you are porting from somewhere else

if $var is null date(datestring, $var) is equal to date(datestring); ie: the current date

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.