Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7969705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:16:44+00:00 2026-06-04T07:16:44+00:00

because i don’t want to use the NSDATE function of Xcode, i tried to

  • 0

because i don’t want to use the NSDATE function of Xcode, i tried to override it with a php script…i found the solution here but it does not work or i can’t get it to work.

this is the code:

 - (NSDate *) CurrentDate
 {
     if ([self hasInternetConnectivity]) // this tests Internet connectivity based off Apple's Reachability sample code
     { 
         NSURL * scriptUrl = [NSURL URLWithString: @"http://<yoursite>.com/<the 2 line php script>.php"];
         NSData * data = [NSData dataWithContentsOfURL: scriptUrl];

         if (data! = nil) {
              NSString * tempString = [NSString stringWithUTF8String: [data bytes]];
              NSDate * currDate = [NSDate dateWithTimeIntervalSince1970: [tempString doubleValue]];
              NSLog (@"String returned from the site is:% @ and date is:% @", tempString, [currDate description]);
              return currDate;
         } else {
              NSLog (@ "nsdata download failed");
              return [NSDate date];
         }
    } else {
        NSLog (@ "InternetConnectivity failed");
        return [NSDate date];
    }
}

Whatever i do it returns errors as in hasInternetConnectivity does not exist in @interface etc..

i just pasted the code into the NAME.m file but it does not want to work..

what i am trying is to get the requested date (php time should return something like 20:10:40 ) in a text field.

its just a string…when someone pushes the button it should get the server time and put it in the text field…

what am i doing wrong ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:16:45+00:00Added an answer on June 4, 2026 at 7:16 am

    This is what i did, it works and it leaks a bit but don’t worry about it its too small:

        NSURL * scriptUrl = [NSURL URLWithString: @"http://www.YOURWEBSITE.com/TIME.php"];
        NSData * data = [NSData dataWithContentsOfURL: scriptUrl];
        serverTime = [[NSMutableString alloc] initWithData:data encoding:NSASCIIStringEncoding];
     NSLog(@"servertime is: %@",servertime);
    

    this is a example of the phpfile to keep it simple:

    <?php
    $servertime = date("H:i:s");
    $string = (string) $servertime;
    echo $string;
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Because I don't want to spend +$12 for the simple-to-use github.com private hosting, I
I want to try to understand the use of these constructs because I don't.
I wanna use listings in LATEX with my own style. Because I don't want
I don't want to use expiration, because I don't know how often my resources
I want to use MemcacheDB instead of Memcached because I don't have a lot
I have a class where I'm using __set . Because I don't want it
For some reason (probably because i don't understand closures) function inResult always returns false
I put return in quotes because I don't want to literally return it. I
I have a problem with class StatefulRetryOperationsInterceptor because I don't know how to use
I am running a synchronise process on the main thread because I don't want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.