Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Wyswietlanie Daty!, Jak wstawic "0" do miesiaca?!
preze$$$
post
Post #1





Grupa: Zarejestrowani
Postów: 4
Pomógł: 0
Dołączył: 2.05.2005

Ostrzeżenie: (0%)
-----


Witam serdecznie (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

Mam taki skrypcik:

<script language="javascript">

var DDMMYY =0
var MMDDYY =1

function getdate(mode)
{
var now = new Date();
var dayNr = ((now.getDate()<10) ? "0" : "")+ now.getDate();
if (mode==DDMMYY)
var MonthDayYear =(dayNr+"."+(now.getMonth()+1)+"."+now.getFullYear());
else
var MonthDayYear =((now.getMonth()+1)+"."+dayNr+"."+now.getFullYear());

return MonthDayYear;
}

function gettime()
{
var now = new Date();

var ampm = (now.getHours() >= 12) ? " P.M." : " A.M."
var hours = now.getHours();
hours = ((hours > 12) ? hours - 12 : hours);

var minutes = ((now.getMinutes() < 10) ? ":0" : ":") + now.getMinutes();
var seconds = ((now.getSeconds() < 10) ? ":0" : ":") + now.getSeconds();
var TimeValue =(" " + hours + minutes + seconds + " " + ampm);

return TimeValue;
}
</script>
<script language="javascript">document.write(getdate(DDMMYY));</script>

Mecze sie z nim okrutnie, nie moge poradzic sobie z tym, aby miesiac byl wyswietlany w formie "05", czyli z zerem (oczywiscie dla 9 pierwszych miesiecy) (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)
I jeszcze jedno, mam go w <body> a chcialbym wyswietlac po "src" z pliku - co zrobic?
Prosze o pomoc (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)


pozdrawiam (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

Ten post edytował preze$$$ 3.05.2005, 18:43:12
Go to the top of the page
+Quote Post
dr_bonzo
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 5 724
Pomógł: 259
Dołączył: 13.04.2004
Skąd: N/A

Ostrzeżenie: (0%)
-----


Kod
var miesiac = ( now.getMonth() < 10 ) ? '0' + now.getMonth() : now.getMonth();

Masz tak samo zrobione dla godzin / minut
Go to the top of the page
+Quote Post
tiraeth
post
Post #3





Grupa: Przyjaciele php.pl
Postów: 1 789
Pomógł: 41
Dołączył: 30.10.2003
Skąd: Wrocław

Ostrzeżenie: (0%)
-----


Proszę Was wszystkich.. umieszczajcie kody w odpowiednich znacznikach BBCode (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif) Czy to tak wiele ?

Poniżej kod, żeby ludzie już nie sklejali i mieli spokój (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Kod
<script language="javascript">
var DDMMYY =0
var MMDDYY =1
function getdate(mode)
{
   var now = new Date();
   var dayNr = ((now.getDate()<10) ? "0" : "")+ now.getDate();
   var miesiac = ((now.getMonth()+1) < 10) ? '0'+(now.getMonth()+1) : (now.getMonth()+1);
   if (mode==DDMMYY)
      var MonthDayYear =(dayNr+"."+miesiac+"."+now.getFullYear());
   else
      var MonthDayYear =(miesiac+"."+dayNr+"."+now.getFullYear());

   return MonthDayYear;
}

function gettime()
{
   var now = new Date();

   var ampm = (now.getHours() >= 12) ? " P.M." : " A.M."
   var hours = now.getHours();
   hours = ((hours > 12) ? hours - 12 : hours);

   var minutes = ((now.getMinutes() < 10) ? ":0" : ":") + now.getMinutes();
   var seconds = ((now.getSeconds() < 10) ? ":0" : ":") + now.getSeconds();
   var TimeValue =(" " + hours + minutes + seconds + " " + ampm);

   return TimeValue;
}
</script>
<script language="javascript">document.write(getdate(DDMMYY));</script>

...proponuję zamknąć temat...

Ten post edytował volture 3.05.2005, 19:16:25
Go to the top of the page
+Quote Post
preze$$$
post
Post #4





Grupa: Zarejestrowani
Postów: 4
Pomógł: 0
Dołączył: 2.05.2005

Ostrzeżenie: (0%)
-----


@volture

Dzieki stary za podpowiedz (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) Jak zauwazyles moja imponujaca liczbe postow, to sie zorientowales, ze jestem poczatkujacy, i na tym forum i na plaszczyznie skryptow. Ale ucze sie (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)
Przyjalem do wiadomosci i bedzie teraz piknie kod podawany...
Uwaga robie probke, bo nie wiem czy to ten znacznik, hahaha:

Kod
<script language="javascript">


P.S.
Oki - juz wiem o co chodzi - taka proscizna (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)


pozdrawiam (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

Ten post edytował preze$$$ 4.05.2005, 08:48:50
Go to the top of the page
+Quote Post
nospor
post
Post #5





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Cytat
Uwaga robie probke, bo nie wiem czy to ten znacznik, hahaha:

Podczas tworzenia posta masz opcję "podgląd posta", która umozliwia podejrzenie posta przed jego wysłaniem.
Poza tym, jak już wyślesz zŁego posta, to możesz go edytować i poprawić.
Go to the top of the page
+Quote Post
preze$$$
post
Post #6





Grupa: Zarejestrowani
Postów: 4
Pomógł: 0
Dołączył: 2.05.2005

Ostrzeżenie: (0%)
-----


@nospor

Dokladnie tak, wiem wiem, dzieki...
To tak wyszlo z rozpedu (pedu) dzisiejszego zyciowego (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)
Przeca to nie pierwsze form, w ktorym udzial biore, hihihi... Alem sie zamotal (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)


pozdrawiam (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 24.08.2025 - 13:39