Saturday, 18 October 2014

Adding an Existing Project from Local Machine to Github using Commands

In this post I will describe to upload an existing project from local machine to Github.

The steps are as following:

Step-1. Create a new repository on GitHub. Do not initialize the new repository with a README file.

Step-2. In Terminal, change the current working directory to your local project.

Step-3. Initialize the local directory as a Git repository.
            
             $ git init
Step-4. Add the files in your new local repository. This stages them for the first commit.
             $ git add .
Step-5. Commit the files that you've staged in your local repository.
             $ git commit -m ‘First Commit’
Step-6. In your GitHub repository, in the right sidebar, copy the remote repository URL.
Step-7. In Terminal, add the URL for the remote repository where your local repostory will be pushed. 
            $ git remote add origin <remote repository URL>
Step-8. Verifies the new remote URL
            $ git remote -v
Step-9. Push the changes in your local repository to GitHub.
            $ git push origin master
Now your local project should be available on github repository.

I hope you would have liked the post.
Thanks

Monday, 23 June 2014

         Date Time Converion According to  TimeZone in iOS



Local timezone to other time zone:

//creating object of NSDateFormatter
NSDateFormatter *dateFormatter=[[NSDateFormatter alloc] init];

//setting format for date
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];

//setting timezone for dateFormatter
dateFormatter.timeZone=[NSTimeZone localTimeZone];

//getting localdate from system
NSString *localDate =[dateFormatter stringFromDate:[NSDate date]];
//Convert from string to date
NSDate *serverDate = [dateFormatter dateFromString:localDate];

//setting the dateformatter timezone according to which time needed
dateFormatter.timeZone=[[NSTimeZone alloc] initWithName:@"America/New_York"];

//getting date in desired formate
NSString *date =[dateFormatter stringFromDate:serverDate];




Other timezone to local time zone:
NSString *serverDateString=@"2014-06-19 10:50:10";
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.timeZone=[[NSTimeZone alloc] initWithName:@"America/New_York"];
dateFormatter.dateFormat=@"yyyy-MM-dd HH:mm:ss";
//Convert from string to date
NSDate *dateObject = [dateFormatter dateFromString:serverDateString];
//setting dateformatter to according to local timezone
dateFormatter.timeZone= [NSTimeZone localTimeZone];
//Now back from date to string
NSLog(@"From date to string: %@", [dateFormatter stringFromDate:dateObject]);
[dateFormatter setDateFormat:@"hh:mm a"];
NSString *time =[dateFormatter stringFromDate:dateObject];