Date problem
2 posters
Page 1 of 1
Date problem
Hey! I hope somebody can help me.
Code place: viewtopic_body
I have chrome
version: phpBB2
Try forum: http://forum-try-here.forumotion.co.uk/t37-hey
I want change date in postbody. What i want? Just i want other words. I have got java code, only changed the top message. BUT I want all "Today at" in this page.
So what i would like? For example;
all "Today at" in to --> "we was here today"
I think in my code miss some replay or something, but i don't know what is the replay in java language xD... Can somebody help me? Good bless you if you guys can!
My java code:
in the viewtopic_body:
Code place: viewtopic_body
I have chrome
version: phpBB2
Try forum: http://forum-try-here.forumotion.co.uk/t37-hey
- settings:
- Problem:
I want change date in postbody. What i want? Just i want other words. I have got java code, only changed the top message. BUT I want all "Today at" in this page.
So what i would like? For example;
all "Today at" in to --> "we was here today"
I think in my code miss some replay or something, but i don't know what is the replay in java language xD... Can somebody help me? Good bless you if you guys can!
My java code:
- Code:
document.getElementById('latepost').innerHTML=document.getElementById('latepost').innerHTML.replace(/Today at/,"we was here today ");
in the viewtopic_body:
- Code:
<span id="latepost">{postrow.displayed.POST_DATE} </span>
Last edited by Duckbunny80 on September 20th 2019, 7:12 pm; edited 1 time in total
Re: Date problem
Your javascript(java is another language) only targets the first element. To target all of the elements, you need to use this code:
You will need to wrap this code in a DOMContentLoaded event listener, but I suppose you already know how to do that. Let me know if you need help with that. If you add the code to the template, you may be able to directly use the code with no modifications.
One last thing, "we was" is not correct english. The correct form is "we were".
- Code:
Array.from(document.querySelectorAll("#latepost")).forEach((elem)=>{
elem.innerHTML=elem.innerHTML.replace("Today at", "we was here today");
})
You will need to wrap this code in a DOMContentLoaded event listener, but I suppose you already know how to do that. Let me know if you need help with that. If you add the code to the template, you may be able to directly use the code with no modifications.
One last thing, "we was" is not correct english. The correct form is "we were".
Guest- Guest
Re: Date problem
Hello dear!
Thanks it oke but i have more question.
If i want change all yesterday too can I? Or is this just for one?
update:
I I tried it: Today is working thanks, BUT with "Yesterday at" no. Why?
Thanks it oke but i have more question.
If i want change all yesterday too can I? Or is this just for one?
update:
I I tried it: Today is working thanks, BUT with "Yesterday at" no. Why?
Re: Date problem
Hello again,
Replace the code with this one:
.
The text before the
(called the key) is the value that needs to be replaced. The text after
(called the value) is the replacement for the first value. You can add as many lines as you want. You can also remove one, or edit it as you see fit. The comma separated the pairs. It's not necessary to leave a comma at the end of the last line, but it's generally a good idea so that you don't forget to add it later on. Let me know if the code works, or if you want me to explain it as I did in the first post.
Replace the code with this one:
- Code:
var c={
"Today at":"we was here today",
"am":"...",
}, _keys=Object.keys(c);
Array.from(document.querySelectorAll("#latepost")).forEach((elem)=>{
var h=elem.innerHTML;
_keys.forEach((key)=>{
h=h.replace(key, c[key]);
});
elem.innerHTML=h;
})
|
The text before the
|
|
Guest- Guest
Re: Date problem
Ohhh man you are a very intelligent, and kind. Sooo sooo thank you.
problem is Solved.
problem is Solved.
Re: Date problem
Thank you for your help @Occultist
Problem solved & topic archived.
|
Similar topics
» Report generation with "Join date" and "Last visit" date
» Can't change the date
» remove T and Z from date
» Date and time
» Regaining Old Creation Date.
» Can't change the date
» remove T and Z from date
» Date and time
» Regaining Old Creation Date.
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum