/    Sign up×
Community /Pin to ProfileBookmark

Can anyone help me covert my JavaScript code to php.

I have this code in JavaScript and I need to make it in php.
JavaScript code:

<!doctype html>
<html>
<head>
<meta charset=”utf-8″/>
<title> Javascript introduction </title>
<script type=”text/javascript”>
var letters = new Array(“A”,”B”,”J”,”D”,”H”,”O”,”Z”);

var days_letters = new Array (“H”, “J”, “A”, “O”, “D”, “B”, “Z”);
var months_letter = new Array (“Z”, “B”, “J”, “H”, “O”, “A”, “B”, “D”, “H”, “Z”, “A”, “J”);
var small_century_letters = new Array (“H”, “B”, “Z”, “D”, “A”, “O”, “J”, “Z”,”H”, “B”, “Z”, “D”, “A”, “O”, “J”, “Z”,”H”, “B”, “O”, “D”, “A”, “O”, “J”, “Z”,”H”, “B”, “O”, “D”, “A”, “O”);
var full_day = {H: “Thursday”, J: “Tuesday”, A: “Sunday”, O: “Friday”, D: “Wednesday”, B: “Monday”, Z: “Saturday”};
var Z=7; var B=2; var J=3; var H=5; var O=6; var D=4; var A=1;

var big_century = 210;
var small_century = 30;

function years(year){
var remain_of_big_century = year % big_century;
var remain_of_small_century = remain_of_big_century % small_century;

var division = remain_of_big_century / small_century;
var div_round= Math.ceil(division);

var the_letter_in_small_century = small_century_letters[(remain_of_small_century + 29) %30];
var the_letter_of_the_first_day_in_days_letter = days_letters[(days_letters.indexOf(the_letter_in_small_century) + div_round – 1) % 7];
var first_day_of_first_month = full_day[the_letter_of_the_first_day_in_days_letter];

document.write(“the remain of big century is: “+ remain_of_big_century + “<br/>”);
document.write(“the remain of small century is: “+ remain_of_small_century + “<br/>”);
document.write(“the division result: “+ div_round + “<br/>”);

document.write(” the letter in the small_century_letters: “+ the_letter_in_small_century +”<br/>”);
document.write(” the letter in the days_letters: “+ the_letter_of_the_first_day_in_days_letter +”<br/>”);
document.write(” first day of Muharam is: “+ first_day_of_first_month +”<br/>”);
}
years(1442);
</script>
</head>
<body>
</body>

</html>
——————————————————————-

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmJan 17.2015 — What is a 'big century' and 'small century'?
Copy linkTweet thisAlerts:
@mohsen1989authorJan 18.2015 — Those are variables.

I am doing my own calendar. Actually it is not a calendar, but it is a form that tell the user what is the first day of each month in the entered or desired year.

My calendar is not Gregorian calendar. It is a different calender, and I have my own calculation.

It is kind of strange for must people because they know that a century is 100 year, but mine is a 210 year.
Copy linkTweet thisAlerts:
@ginerjmJan 18.2015 — Of Course they are variables!

Good luck with that.
Copy linkTweet thisAlerts:
@mohsen1989authorJan 19.2015 — What's up genius?

Can anyone help me with this problem?

my knowledge did not help me to convert this code into PHP.
Copy linkTweet thisAlerts:
@jedaisoulJan 19.2015 — To convert your code is a big ask. Normally, we'd help with specific problem(s) you are having in doing it yourself! So being sarky is counter-productive as it does not encourage us to bother... ?
×

Success!

Help @mohsen1989 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...