存储时间戳00:00:00(Store timestamp with time 00:00:00)
我想在time数据库中存储时间戳为
00:00:00
。
以下代码:$start_date = Carbon::createFromFormat('d-m-Y', $date_interval["start_date"]); $end_date = Carbon::createFromFormat('d-m-Y', $date_interval["end_date"]);
将当前时间添加到日期,当我仅提供没有时间指定的日期时。
我需要这个,因为我需要从数据库中检索内部整数,这应该是一天的开始。什么是存储这个'一天的开始'的最佳方式?
I want to store a timestamp in the database with time component as
00:00:00
.
The following code:$start_date = Carbon::createFromFormat('d-m-Y', $date_interval["start_date"]); $end_date = Carbon::createFromFormat('d-m-Y', $date_interval["end_date"]);
adds the current time to the date, when I provide a date only without time specification.
I need this because I need to retrieve the internal integer from the database afterwards which should be the start of the day.What is the best way to store this 'start of day'?
原文:https://stackoverflow.com/questions/27693391
最满意答案
这就是我在做的方式
例如,如果您有三个ViewControllers,并且其中任何一个都可能被NavigationController推送:
ViewControllerA ViewControllerB ViewControllerC
然后你需要做的是:
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { if ([[self.navigationController topViewController] isKindOfClass:[ViewControllerA class]]) { //do sth } if ([[self.navigationController topViewController] isKindOfClass:[ViewControllerB class]]) { //do sth } if ([[self.navigationController topViewController] isKindOfClass:[ViewControllerC class]]) { //do sth } }//end of code
Hey guys, i did it in a simple way. In every view controller i had, i removed all objects and assigned an object to an array in the appdelegate. So this way, everytime i go to a new view, the value is different.
So in appdidrecieveremotenotification, i can check that array and decide on what to do accordingly.
Its just a simple way of checking.
相关问答
更多-
iOS通知。(iOS Notifications. Which one to use?)[2021-12-21]
您可以将所有事件保存为核心数据,然后每次启动应用程序时或当您的主视图出现在该周的所有事件中时加载并设置预设的本地通知。 一旦事件被安排,你在实体中设置一个标志,例如hasBeenNotified。 希望能帮助到你。 I decided to offer local notifications without repeat functionality. This decision was made after chatting with a few users. Better to offer somethi ... -
在检查了您在gitHub上使用的库的问题窗格之后,我看到有一些其他人遇到了类似的问题,并且已经发布了他们的解决方案。 他们基本上将调用侧边菜单的UIViewController嵌入到UINavigationController 。 github上报告的问题被标记为关闭,并且它是#255 After checking the issues pane on the library you use on gitHub, I saw that there are couple other people having ...
-
在包含containerView的VC类中,确保为其添加IBOutlet @IBOutlet var containerView:UIView! // 当您将containerView拖动到视图并给出约束时,它会使用该容器中的segue创建一个VC View,然后单击DestinationVC并从Editor-> EmbedIn-> NavigationController // In the class of the VC that contains the containerView , make s ...
-
呈现一个UIViewController模态地创建一个全新的导航堆栈。 你可以做这样的事情: //Create the view you want to present modally UIViewController *modalView = [[UIViewController alloc] init]; //Create a new navigation stack and use it as the new RootViewController for it UINavigationControll ...
-
这是一个合乎逻辑的问题。 导航控制器是视图控制器的容器。 因此它没有与之相关的视图。 尝试这样的事情: UIView *currentView = [[myNavigationController visibleViewController] view]; So, I've finally find out how to fix this problem. But I don't understand why it's only occuring only in iOS5. So the problem ...
-
这就是我在做的方式 例如,如果您有三个ViewControllers,并且其中任何一个都可能被NavigationController推送: ViewControllerA ViewControllerB ViewControllerC 然后你需要做的是: -(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { if ([[self.navigat ...
-
如何将视图推送到导航堆栈并删除当前的导航堆栈?(How to push a view to the navigation stack and remove the current one?)[2021-08-28]
关于你最后一个不推动的例子,这是否工作? NSMutableArray *viewControllers = [NSMutableArray arrayWithArray: self.navigationController.viewControllers]; [viewControllers removeObjectIdenticalTo:self]; [viewControllers addObject:controller]; [self.navigationController setViewCon ... -
如果你实际上只是提出一个你将在以后删除的view , 那么最好为您的view创建一个ViewController类,并使用以下方式以模态方式呈现它: [self presentViewController:yourViewControllerObject animated:NO completion:nil]; 您可以稍后使用以下命令删除此view : [self dismissViewControllerAnimated:NO completion:nil]; 希望这可以帮助 ! Thanks to ...
-
您可以通过调用presentModalViewController:animated:来显示标签栏控制器presentModalViewController:animated:而不是将其推送到导航堆栈。 如果您根本不需要第一个导航控制器,则应该用标准视图控制器替换它。 You could display the tab bar controller by calling presentModalViewController:animated: instead of pushing it to a navig ...
-
这应该工作: UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes]; if (types == UIRemoteNotificationTypeNone) // Disabled This should work: UIRemoteNotificationType types = [[UIApplication sharedApplication] en ...