Jump to content

Ramamoorthy

Members
  • Posts

    12
  • Joined

  • Last visited

Ramamoorthy's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello, I am trying to convert the Date,Month,Year, Hour:Minutes:Seconds to Timestamp and Timestamp to Date,Month,Year, Hour:Minutes:Seconds . I ve setted the Timezone as Asia/Calcutta in the code . The Code works well when I run in my localhost , But when I run the code in my server located in Dallas,TX,USA the data changes largely . For example : The Timestamp generated for 24-May-2014 00:00:00 is 1400889600 in my localhost (Chennai, India). The Timestamp generated for 24-May-2014 00:00:00 is 1400914800 in my server (Dallas, TX, USA). why this changes occurs even though I ve setted the timezone ? Code: <?php $date = new DateTime(null, new DateTimeZone('Asia/Calcutta')); $ist = ($date->getTimestamp() + $date->getOffset()); echo "<h1>Current Timestamp and Date and Time for India</h1> <b>".$ist.'</b>';echo " ";echo '<b>'.date('D, d M Y H:i:s ',$ist).'+0530</b>'; echo "<br />"; ?> <h1>Timestamp to Date and Time Converter</h1> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input type="number" name="timestamp_to_dt_timestamp" id="timestamp_to_dt_timestamp" /> <input type="submit" id="submit" name="submit" value="Submit" /> </form> <?php if (isset($_POST['timestamp_to_dt_timestamp'])) { $timestamp_to_dt_timestamp = $_POST['timestamp_to_dt_timestamp']; echo 'Date and Time for the Timestamp :'.$timestamp_to_dt_timestamp.' is : '.date('D, d M Y H:i:s ',$timestamp_to_dt_timestamp); } ?> <h1>Date and Time to TimeStamp Converter</h1> <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>"> Date (no preceeding zeros): <input type="text" name="dt_to_timestamp__date" id="dt_to_timestamp__date" value="<?php echo date('j',$ist) ?>" /><br /> Month (number): <input type="text" name="dt_to_timestamp__month" id="dt_to_timestamp__month" value="<?php echo date('n',$ist) ?>" /><br /> Year : <input type="text" name="dt_to_timestamp__year" id="dt_to_timestamp__year" value="<?php echo date('Y',$ist) ?>" /><br /> Hours : <input type="text" name="dt_to_timestamp__hours" id="dt_to_timestamp__hours" value="00" /><br /> Minutes : <input type="text" name="dt_to_timestamp__mins" id="dt_to_timestamp__mins" value="00" /><br /> Seconds : <input type="text" name="dt_to_timestamp__sec" id="dt_to_timestamp__sec" value="00" /><br /> <input type="submit" id="submit" name="submit" value="Submit" /> <p>Leave the time field(s) if you don't know the exact time.</p> </form> <?php if (isset($_POST['dt_to_timestamp__date'])) { $dt_to_timestamp__date = $_POST['dt_to_timestamp__date']; } if (isset($_POST['dt_to_timestamp__month'])) { $dt_to_timestamp__month = $_POST['dt_to_timestamp__month']; } if (isset($_POST['dt_to_timestamp__year'])) { $dt_to_timestamp__year = $_POST['dt_to_timestamp__year']; } if (isset($_POST['dt_to_timestamp__hours'])) { $dt_to_timestamp__hours = $_POST['dt_to_timestamp__hours']; } if (isset($_POST['dt_to_timestamp__mins'])) { $dt_to_timestamp__mins = $_POST['dt_to_timestamp__mins']; } if (isset($_POST['dt_to_timestamp__sec'])) { $dt_to_timestamp__sec = $_POST['dt_to_timestamp__sec']; } if (isset($_POST['dt_to_timestamp__date'])) { if (isset($_POST['dt_to_timestamp__month'])) { if (isset($_POST['dt_to_timestamp__year'])) { if (isset($_POST['dt_to_timestamp__hours'])) { if (isset($_POST['dt_to_timestamp__mins'])) { if (isset($_POST['dt_to_timestamp__sec'])) { echo date(mktime($dt_to_timestamp__hours, $dt_to_timestamp__mins, $dt_to_timestamp__sec, $dt_to_timestamp__month, $dt_to_timestamp__date, $dt_to_timestamp__year)); } } } } } } ?> What I am missing ? -Thanks timestamp.php
  2. I have tried something called concatenating . but I am not sure whether I have rightly coded or not. but it doesnt gets the variable instead gets the variable value ..
  3. Hi guys . I have came up here with one horrible question. I ve been searching around the web for more than 2 weeks and can't get the answer .. here the codings: Index.php <?php require_once($_SERVER['DOCUMENT_ROOT'] . '/db.php'); echo $varone_latest; echo"<br />"; echo $varone_latest_string;?> db.php <?php $varone_1234 = "1234th variable" $varone_1234_string = "this is the 1234 th line"; /* and more 100 variables related to varone_1234*/ $varone_latest = $varone_1234; ?> now in the index.php the first echo $varone_latest; prints the right string . but the second echo $varone_latest_string; doesn't gives and it will give error of undefined variable .. now my problem I want to print the value of $varone_1234_string; in Index.php instead of $varone_latest_string; I know it is not possible . but I have came up with idea..which is . first the php have to determine what variable assigned to $varone_latest . answer will be $varone_1234 .. and then it has to join remaining " _string" and have to convert it as variable .. then it has to print .. How to do that ...? I hope I am not clear in my question . so any help me to build the question well.. example in javascript used by Disqus.com var disqus_shortname = 'filedelivery'; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js'; here shortname is filedelivery .. and deafult url for loading is .disqus.com/embed.js .. the js embeds shortname and default url and makes it as a url and then loads the file from the created url .. Note: this is just the example that I have gave in js .. anyway to achieve it in php ..?
  4. Hi, I want to create a PHP program that sends email to my mail address if it detects any change in the given url . I ll open the php file in browser and so no need to use cron jobs . Kindly help me how to start . I have completely no idea to what to do . I know only concept : Saves the last html code or webview of the webpage in db. if there is changes in html code or webview it sends e-mail . (I don't want to use page2rss - check interval more than 5 hours). -Thanks
  5. anyway to create without database .? I dont know mysql !
  6. I am creating a download counter for my website , where the counts will be saved in a text file. and then it will be incremented everytime the page gets the visit . It contains 3 files; counter.php - increments the count everytime the page gets hits log.txt - numerical value will be stored here display.php - gets the content from log.txt and prints it . Codes Counter.php <html><head> <meta http-equiv="refresh" content="0; url=http://localhost:1000/hits/test.zip"> </head> <?php $fp = fopen("log.txt", "r"); $count = fread($fp, 1024); fclose($fp); $count = $count + 1; $fp = fopen("counterlog.txt", "w"); fwrite($fp, $count); fclose($fp); ?> display.php <?php$fp = fopen("log.txt", "r"); $count = fread($fp, 1024); fclose($fp); echo "<span class='span-counter'>" . $count . "</span>"; ?> log.txt 1 The above codes works fine . It increments the count and writes to text file . and I can display the Number of Downloads wherever I want . Now I want to make it for more than 100 downloads(100 types) .. that uses same log.txt file for writing . How it is possible ..? can I write in specific line number in php using fwrite or someother function .? or I have to use database for this ? -Thanks
  7. thanks for the idea. I can add the newly implemented variable .. only if I have some 100 or 200 pages .. what If I have some thousands of page . anyway I ll surely consider this , but man keep giving guidance to me .
  8. This post could help more to the question. I have 4 files db.php - databse file include.php - global include file like header and footer soft1.php - single php file for software listing soft2.php - again single php file for software listing. CODES in db.php <?php $bro_aaaa= "google chrome" $bro_aaaa_aa = "28.0" ?> in include.php <?php echo $softwarename; echo $softwareversion; ?> in soft1.php <?php require './db.php'; $softwarename = $bro_aaaa; $softwareversion = $bro_aaaa_aa; include './include.php'; ?> so If I now change the Include.php for adding two more feature like this . <?php echo $softwarename; echo $softwareversion; echo $softwareversion_size; echo $softwareversion_releasedate; ?> and add new file to server called soft2.php <?php require './db.php'; $softwarename = $bro_aaaa; $softwareversion = $bro_aaaa_aa; $softwareversion_size = $bro_aaaa_aa_size; $softwareversion_releasedate = $bro_aaaa_aa_reldate; include './include.php'; ?> (I will add needed informations in the database - db.php) now my soft1.php page will lead to error because it doesnt know what new 2 variables is . but I dont want to use isset - and if it isset it have to show , otherwise it ll will not show the new2 feature .because I need to implement the feature for all softwares (all new and old pages).. how can achieve new feature implementation throughout the site ..?
  9. I am not sure that you entirely got my question . But I dont want to check whether the variable is declared or not . I want to implement the feature all over the site ..
  10. But I want to implement the new feature to the old pages also .. Thanks Ch0cu3ri ll try . The bro , aaaa and aa are unique IDs . used to maintain website .
  11. Hi all, I am coding for Windows software download website - there I ll be having more than 300 softwares . every category will be having its unique ID , every software will be having its unique ID, every software version will be having its unique ID. Example : For category Browser : id will be bro for software chrome : id will be bro_aaaa for chrome 28.0 : id will be bro_aaaa_aa here how I ll print the informations in website // db.php // <?php $bro = "Browsers"; $bro_aaaa = "Google Chrome"; $bro_aaaa_aa = "28.0" ?> -----(end of file db.php) // include.php // <?php echo $softwarecat; echo $softwarename; echo $softwareversion; ?> ---------(end of file include.php) // software-page.php // <?php require_once($_SERVER['DOCUMENT_ROOT'] . '/db.php'); $softwarecat =$bro; $softwarename =$bro_aaaa; $softwareversion =$bro_aaaa_aa; include './include.php'; ?> /* using include.php because just changing only this file , I can implement changes all over the website */ so the server will print everything rightly as mentioned in the db.php Now . if I change the include.php as like below . <?php echo $softwarecat; echo $softwarename; echo $softwareversion; echo $softwaresize; /* listen - new feature */ ?> It will lead to error in all software pages as I haven't specified the value for $softwaresize . but I can specify it for new software pages . How can I fix it . Only way I know is below in softwarepage.php <?php require_once($_SERVER['DOCUMENT_ROOT'] . '/db.php'); $softwarecat = bro; $softwareid = aaaa; $softwareversionid = aa; include './include.php'; ?> now I need help for this part . the server has to replace the $softwarecat as $bro; and $softwareid as aaaa; and $softwareversionid as aa; if this happens I can completely change the include.php file as my wish . any help is greatly appreciated . I am here to clarify any doubt regarding my question (Note : I am very new to this site and I don't know how to even ask a question. anyone please guide) please dont recommend to use mysql - I think it can be easily done . But I dont know mysql (even I know only very little php)
  12. Hi all, I am coding for Windows software download website - there I ll be having more than 300 softwares . every category will be having its unique ID , every software will be having its unique ID, every software version will be having its unique ID. Example : For category Browser : id will be bro for software chrome : id will be bro_aaaa for chrome 28.0 : id will be bro_aaaa_aa here how I ll print the informations in website // db.php // $bro = "Browsers"; $bro_aaaa = "Google Chrome"; $bro_aaaa_aa = "28.0" -----(end of file db.php) // include.php // <?php echo $softwarecat; echo $softwarename; echo $softwareversion; ?> ---------(end of file include.php) // software-page.php // <?php require_once($_SERVER['DOCUMENT_ROOT'] . '/db.php'); $softwarecat =$bro; $softwarename =$bro_aaaa; $softwareversion =$bro_aaaa_aa; include './include.php'; ?> /* using include.php because just changing only this file , I can implement changes all over the website */ so the server will print everything rightly as mentioned in the db.php Now . if I change the include.php as like below . <?php echo $softwarecat; echo $softwarename; echo $softwareversion; echo $softwaresize; /* listen - new feature */ ?> It will lead to error in all software pages as I haven't specified the value for $softwaresize . but I can specify it for new software pages . How can I fix it . Only way I know is below in softwarepage.php <?php require_once($_SERVER['DOCUMENT_ROOT'] . '/db.php'); $softwarecat = bro; $softwareid = aaaa; $softwareversionid = aa; include './include.php'; ?> now I need help for this part . the server has to replace the $softwarecat as $bro; and $softwareid as aaaa; and $softwareversionid as aa; if this happens I can completely change the include.php file as my wish . any help is greatly appreciated . I am here to clarify any doubt regarding my question (Note : I am very new to this site and I don't know how to even ask a question. anyone please guide)
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.